- Timestamp:
- 2010/08/24 14:58:32 (14 years ago)
- bzr:base-revision:
- ohkouchi@loop-az.jp-20100820090626-dkyj2ngdh7vklaow
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/class/SC_Query.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_Query.php
data/class/db/SC_DB_DBFactory.php 15123@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fdb%2FSC_DB_DBFactory.php
data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php 15123@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fdb%2Fdbfactory%2FSC_DB_DBFactory_MYSQL.php
data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php 15123@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fdb%2Fdbfactory%2FSC_DB_DBFactory_PGSQL.php
data/class/helper/SC_Helper_DB.php 15176@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_DB.php
data/class/helper/SC_Helper_Session.php 15277@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_Session.php
html/install/index.php 16809@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Findex.php
test/class/SC_Query_Test.php sc_query_test.php-20100803024127-ljzonih8f5jpan9o-1
test/class/helper/SC_Helper_DB_Test.php 15242@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Ftest%2Fclass%2Fhelper%2FSC_Helper_DB_Test.php- bzr:mapping-version:
- v4
- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20100824055828-2oy1qb3wcp85i76l
- bzr:revno:
- 2273
- bzr:revprop:branch-nick:
- branches/version-2_5-dev
- bzr:root:
- branches/version-2_5-dev
- bzr:text-parents:
data/class/SC_Query.php ohkouchi@loop-az.jp-20100819104758-beubop5hq0pwdqhx
data/class/helper/SC_Helper_Session.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
html/install/index.php ohkouchi@loop-az.jp-20100819104758-beubop5hq0pwdqhx
test/class/SC_Query_Test.php ohkouchi@loop-az.jp-20100803111301-u8ph4za35y4il0dh
test/class/helper/SC_Helper_DB_Test.php ohkouchi@loop-az.jp-20100726081655-tqxqwy02bxqhswcu- bzr:timestamp:
- 2010-08-24 14:58:28.038000107 +0900
- bzr:user-agent:
- bzr2.1.2+bzr-svn1.0.2
- svn:original-date:
- 2010-08-24T05:58:28.038000Z
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php
r18789 r18790 60 60 61 61 /** 62 * テーブルの存在をチェックする.63 *64 * @param string $table_name チェック対象のテーブル名65 * @param string $dsn データソース名66 * @return テーブルが存在する場合 true67 */68 function sfTabaleExists($table_name, $dsn = "") {69 $dbFactory = SC_DB_DBFactory_Ex::getInstance();70 $dsn = $dbFactory->getDSN($dsn);71 72 $objQuery =& SC_Query::getSingletonInstance();73 // 正常に接続されている場合74 if(!$objQuery->isError()) {75 list($db_type) = split(":", $dsn);76 /*77 * XXX MySQL で, 何故かブレースホルダが使えない.78 */79 $sql = $dbFactory->getTableExistsSql($table_name);80 $arrRet = $objQuery->getAll($sql);81 if(count($arrRet) > 0) {82 return true;83 }84 }85 return false;86 }87 88 /**89 62 * カラムの存在チェックと作成を行う. 90 63 * … … 106 79 $dsn = $dbFactory->getDSN($dsn); 107 80 81 $objQuery =& SC_Query::getSingletonInstance($dsn); 82 108 83 // テーブルが無ければエラー 109 if(!$this->sfTabaleExists($table_name, $dsn)) return false; 110 111 $objQuery =& SC_Query::getSingletonInstance(); 84 if(!in_array($table_name, $objQuery->listTables())) return false; 85 112 86 // 正常に接続されている場合 113 87 if(!$objQuery->isError()) { … … 115 89 116 90 // カラムリストを取得 117 $arrRet = $dbFactory->sfGetColumnList($table_name); 118 if(count($arrRet) > 0) { 119 if(in_array($col_name, $arrRet)){ 120 return true; 121 } 91 $columns = $objQuery->listTableFields($table_name); 92 93 if(in_array($col_name, $columns)){ 94 return true; 122 95 } 123 96 } … … 126 99 if($add){ 127 100 $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); 128 return true;129 }130 return false;131 }132 133 /**134 * インデックスの存在チェックと作成を行う.135 *136 * チェック対象のテーブルに, 該当のインデックスが存在するかチェックする.137 * 引数 $add が true の場合, 該当のインデックスが存在しない場合は, インデックスの生成を行う.138 * インデックスの生成も行う場合で, DB_TYPE が mysql の場合は, $length も必須となる.139 *140 * @param string $table_name テーブル名141 * @param string $column_name カラム名142 * @param string $index_name インデックス名143 * @param integer|string $length インデックスを作成するデータ長144 * @param string $dsn データソース名145 * @param bool $add インデックスの生成もする場合 true146 * @return bool インデックスが存在する場合とインデックスの生成に成功した場合 true,147 * テーブルが存在しない場合 false,148 * 引数 $add == false でインデックスが存在しない場合 false149 */150 function sfIndexExists($table_name, $col_name, $index_name, $length = "", $dsn = "", $add = false) {151 $dbFactory = SC_DB_DBFactory_Ex::getInstance();152 $dsn = $dbFactory->getDSN($dsn);153 154 // テーブルが無ければエラー155 if (!$this->sfTabaleExists($table_name, $dsn)) return false;156 157 $objQuery =& SC_Query::getSingletonInstance();158 $arrRet = $dbFactory->getTableIndex($index_name, $table_name);159 160 // すでにインデックスが存在する場合161 if(count($arrRet) > 0) {162 return true;163 }164 165 // インデックスを作成する166 if($add){167 $dbFactory->createTableIndex($index_name, $table_name, $col_name, $length());168 101 return true; 169 102 }
Note: See TracChangeset
for help on using the changeset viewer.