source: branches/version-2_5-dev/data/class/db/SC_DB_DBFactory.php @ 20732

Revision 20732, 5.2 KB checked in by nanasess, 13 years ago (diff)

#957(再インストール時、インストール画面「データベースの初期化」で旧DBMSを表示)

  • 再インストール前の data/config/config.php の DB_TYPE を参照していたのを修正
  • SC_DB_DBFactory::getInstance() に DB_TYPE を渡して任意のインスタンスを返せるよう修正
  • SC_DB_DBFactory::sfGetDBVersion() で, 引数の DSN が無効になっていた不具合を修正
  • SC_Helper_DB::sfGetDBVersion() は冗長だったため削除
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once CLASS_REALDIR . 'db/dbfactory/SC_DB_DBFactory_MYSQL.php';
26require_once CLASS_REALDIR . 'db/dbfactory/SC_DB_DBFactory_PGSQL.php';
27
28/**
29 * DBに依存した処理を抽象化するファクトリークラス.
30 *
31 * @package DB
32 * @author LOCKON CO.,LTD.
33 * @version $Id:SC_DB_DBFactory.php 15532 2007-08-31 14:39:46Z nanasess $
34 */
35class SC_DB_DBFactory {
36
37    /**
38     * DB_TYPE に応じた DBFactory インスタンスを生成する.
39     *
40     * @param string $db_type 任意のインスタンスを返したい場合は DB_TYPE 文字列を指定
41     * @return mixed DBFactory インスタンス
42     */
43    function getInstance($db_type = DB_TYPE) {
44        switch ($db_type) {
45        case 'mysql':
46            return new SC_DB_DBFactory_MYSQL();
47            break;
48
49        case 'pgsql':
50            return new SC_DB_DBFactory_PGSQL();
51            break;
52
53        default:
54            return new SC_DB_DBFactory();
55        }
56    }
57
58    /**
59     * データソース名を取得する.
60     *
61     * 引数 $dsn が空の場合は, DEFAULT_DSN の値を返す.
62     * DEFAULT_DSN が未定義の場合は void となる.
63     * $dsn が空ではない場合は, $dsn の値を返す.
64     *
65     * @param string $dsn データソース名
66     * @return void|string データソース名
67     */
68    function getDSN($dsn = "") {
69        if(empty($dsn)) {
70            if(defined('DEFAULT_DSN')) {
71                $dsn = DEFAULT_DSN;
72            } else {
73                return "";
74            }
75        }
76        return $dsn;
77    }
78
79    /**
80     * DBのバージョンを取得する.
81     *
82     * @param string $dsn データソース名
83     * @return string データベースのバージョン
84     */
85    function sfGetDBVersion($dsn = "") { return null; }
86
87    /**
88     * MySQL 用の SQL 文に変更する.
89     *
90     * @param string $sql SQL 文
91     * @return string MySQL 用に置換した SQL 文
92     */
93    function sfChangeMySQL($sql) { return null; }
94
95    /**
96     * 昨日の売上高・売上件数を算出する SQL を返す.
97     *
98     * @param string $method SUM または COUNT
99     * @return string 昨日の売上高・売上件数を算出する SQL
100     */
101    function getOrderYesterdaySql($method) { return null; }
102
103    /**
104     * 当月の売上高・売上件数を算出する SQL を返す.
105     *
106     * @param string $method SUM または COUNT
107     * @return string 当月の売上高・売上件数を算出する SQL
108     */
109    function getOrderMonthSql($method) { return null; }
110
111    /**
112     * 昨日のレビュー書き込み件数を算出する SQL を返す.
113     *
114     * @return string 昨日のレビュー書き込み件数を算出する SQL
115     */
116    function getReviewYesterdaySql() { return null; }
117
118    /**
119     * メール送信履歴の start_date の検索条件の SQL を返す.
120     *
121     * @return string 検索条件の SQL
122     */
123    function getSendHistoryWhereStartdateSql() { return null; }
124
125    /**
126     * ダウンロード販売の検索条件の SQL を返す.
127     *
128     * @return string 検索条件の SQL
129     */
130    function getDownloadableDaysWhereSql() { return null; }
131
132    /**
133     * 文字列連結を行う.
134     *
135     * @param array $columns 連結を行うカラム名
136     * @return string 連結後の SQL 文
137     */
138    function concatColumn($columns) { return null; }
139
140    /**
141     * テーブルのカラム一覧を取得する.
142     *
143     * @deprecated SC_Query::listTableFields() を使用してください
144     * @param string $table_name テーブル名
145     * @return array テーブルのカラム一覧の配列
146     */
147    function sfGetColumnList($table_name) { return array(); }
148
149    /**
150     * テーブルを検索する.
151     *
152     * 引数に部分一致するテーブル名を配列で返す.
153     *
154     * @deprecated SC_Query::listTables() を使用してください
155     * @param string $expression 検索文字列
156     * @return array テーブル名の配列
157     */
158    function findTableNames($expression = "") { return array(); }
159
160    /**
161     * インデックス作成の追加定義を取得する
162     *
163     * 引数に部分一致するテーブル名を配列で返す.
164     *
165     * @param string $table 対象テーブル名
166     * @param string $name 対象カラム名
167     * @return array インデックス設定情報配列
168     */
169    function sfGetCreateIndexDefinition($table, $name, $definition) { return $definition; }
170
171}
172?>
Note: See TracBrowser for help on using the repository browser.