Changeset 18763 for branches/version-2_5-dev/data/class/SC_DbConn.php
- Timestamp:
- 2010/07/26 17:16:59 (14 years ago)
- bzr:base-revision:
- svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:18762
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/class/SC_DbConn.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_DbConn.php
html/define.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Fdefine.php
html/install/index.php 16809@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Findex.php
test/README.txt 18218@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Ftest%2FREADME.txt
test/TestSuite.php 15114@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Ftest%2FTestSuite.php
test/class/SC_DbConn_Test.php 18387@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Ftest%2Fclass%2FSC_DbConn_Test.php
test/class/db/DB_AllTests.php 18218@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Ftest%2Fclass%2Fdb%2FDB_AllTests.php
test/class/db/SC_DB_DBFactory_Test.php 15242@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Ftest%2Fclass%2Fdb%2FSC_DB_DBFactory_Test.php
test/class/db/SC_DB_MasterData_Test.php 15134@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Ftest%2Fclass%2Fdb%2FSC_DB_MasterData_Test.php
test/class/helper/Helper_AllTests.php 18218@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Ftest%2Fclass%2Fhelper%2FHelper_AllTests.php
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
test/class/logger/GC_Log_Log4php_Test.php 18220@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Ftest%2Fclass%2Flogger%2FGC_Log_Log4php_Test.php
test/class/logger/GC_Logger_Test.php 18220@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Ftest%2Fclass%2Flogger%2FGC_Logger_Test.php
test/class/page/LC_Page_Test.php 15114@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Ftest%2Fclass%2Fpage%2FLC_Page_Test.php
test/class/page/Page_AllTests.php 18218@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Ftest%2Fclass%2Fpage%2FPage_AllTests.php
test/require.php require.php-20100726065552-t2b4u96mp8ikqvjf-1- bzr:mapping-version:
- v4
- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20100726081655-tqxqwy02bxqhswcu
- bzr:revno:
- 2246
- bzr:revprop:branch-nick:
- branches/version-2_5-dev
- bzr:root:
- branches/version-2_5-dev
- bzr:text-parents:
data/class/SC_DbConn.php ohkouchi@loop-az.jp-20100623032937-dhwktuevjyk0jv13
html/define.php svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/comu-ver2:18653
html/install/index.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/README.txt svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/comu-ver2:18218
test/TestSuite.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/SC_DbConn_Test.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/db/DB_AllTests.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/db/SC_DB_DBFactory_Test.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/db/SC_DB_MasterData_Test.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/helper/Helper_AllTests.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/helper/SC_Helper_DB_Test.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/logger/GC_Log_Log4php_Test.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/logger/GC_Logger_Test.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/page/LC_Page_Test.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
test/class/page/Page_AllTests.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m- bzr:timestamp:
- 2010-07-26 17:16:55.075999975 +0900
- bzr:user-agent:
- bzr2.1.2+bzr-svn1.0.2
- svn:original-date:
- 2010-07-26T08:16:55.076000Z
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/SC_DbConn.php
r18743 r18763 23 23 24 24 $current_dir = realpath(dirname(__FILE__)); 25 require_once($current_dir . "/../module/ DB.php");25 require_once($current_dir . "/../module/MDB2.php"); 26 26 27 27 $g_arr_objDbConn = array(); … … 61 61 62 62 if ($new) { 63 $this->conn = DB::connect($this->dsn, $options); 63 // TODO singleton の方が良いかも 64 $this->conn = MDB2::connect($this->dsn, $options); 64 65 $g_arr_objDbConn[$this->dsn] = $this->conn; 65 66 67 // TODO MDB2::setCharset() を使った方が良い? 66 68 if (DB_TYPE == 'mysql') { 67 69 $g_arr_objDbConn[$this->dsn]->query('SET NAMES utf8'); // FIXME mysql_set_charset を使える環境では、その方が良さそう (2010/03/03 Seasoft 塚田) … … 72 74 } 73 75 76 $this->conn->setFetchMode(MDB2_FETCHMODE_ASSOC); 74 77 $this->err_disp = $err_disp; 75 78 $this->dbFactory = SC_DB_DBFactory_Ex::getInstance(); … … 77 80 78 81 // クエリの実行 79 function query($n ,$arr = "", $ignore_err = false){82 function query($n ,$arr = array(), $ignore_err = false){ 80 83 // mysqlの場合にはビュー表を変換する 81 84 if (DB_TYPE == "mysql") $n = $this->dbFactory->sfChangeMySQL($n); 82 85 86 $sth = $this->conn->prepare($n); 83 87 if ( $arr ) { 84 $result = $ this->conn->query($n,$arr);85 } else { 86 $result = $ this->conn->query($n);88 $result = $sth->execute($arr); 89 } else { 90 $result = $sth->execute(); 87 91 } 88 92 … … 96 100 97 101 // 一件のみ取得 98 function getOne($n, $arr = ""){102 function getOne($n, $arr = array()){ 99 103 100 104 // mysqlの場合にはビュー表を変換する 101 105 if (DB_TYPE == "mysql") $n = $this->dbFactory->sfChangeMySQL($n); 102 106 107 $sth = $this->conn->prepare($n); 103 108 if ( $arr ) { 104 $ result = $this->conn->getOne($n,$arr);105 } else { 106 $ result = $this->conn->getOne($n);107 } 108 if ($this->conn->isError($result)){ 109 $this->send_err_mail($result ,$n);110 }111 $this->result = $result;112 109 $affected = $sth->execute($arr); 110 } else { 111 $affected = $sth->execute(); 112 } 113 114 if ($this->conn->isError($affected)){ 115 $this->send_err_mail($affected ,$n); 116 } 117 $this->result = $affected->fetchOne(); 113 118 return $this->result; 114 119 } … … 122 127 * @return array データを含む1次元配列。失敗した場合に DB_Error オブジェクトを返します。 123 128 */ 124 function getRow($sql, $arrVal = array(), $fetchmode = DB_FETCHMODE_ASSOC) {129 function getRow($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 125 130 126 131 // mysqlの場合にはビュー表を変換する 127 132 if (DB_TYPE == "mysql") $sql = $this->dbFactory->sfChangeMySQL($sql); 133 134 $sth = $this->conn->prepare($sql); 135 if ($arrVal) { 136 $affected = $sth->execute($arrVal); 137 } else { 138 $affected = $sth->execute(); 139 } 140 if ($this->conn->isError($affected)) { 141 $this->send_err_mail($affected, $sql); 142 } 143 $this->result = $affected->fetchRow($fetchmode); 128 144 129 $result = $this->conn->getRow($sql, $arrVal ,$fetchmode); 130 131 if ($this->conn->isError($result)){ 132 $this->send_err_mail($result ,$sql); 133 } 134 $this->result = $result; 135 return $this->result; 136 } 137 138 function getCol($n, $col, $arr = "") { 145 return $this->result; 146 } 147 148 function getCol($n, $col, $arr = array()) { 139 149 140 150 // mysqlの場合にはビュー表を変換する 141 151 if (DB_TYPE == "mysql") $n = $this->dbFactory->sfChangeMySQL($n); 142 152 153 $sth = $this->conn->prepare($n); 143 154 if ($arr) { 144 $ result = $this->conn->getCol($n, $col,$arr);145 } else { 146 $ result = $this->conn->getCol($n, $col);147 } 148 if ($this->conn->isError($ result)) {149 $this->send_err_mail($ result, $n);150 } 151 $this->result = $ result;155 $affected = $sth->execute($arr); 156 } else { 157 $affected = $sth->execute(); 158 } 159 if ($this->conn->isError($affected)) { 160 $this->send_err_mail($affected, $n); 161 } 162 $this->result = $affected->fetchCol($col); 152 163 return $this->result; 153 164 } … … 161 172 * @return array データを含む2次元配列。失敗した場合に 0 または DB_Error オブジェクトを返します。 162 173 */ 163 function getAll($sql, $arrVal = "", $fetchmode = DB_FETCHMODE_ASSOC) {174 function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 164 175 165 176 // mysqlの場合にはビュー表を変換する … … 176 187 } 177 188 189 $sth = $this->conn->prepare($sql); 190 178 191 if ($arrVal) { // FIXME 判定が曖昧 179 $ result = $this->conn->getAll($sql, $arrVal, $fetchmode);180 } else { 181 $ result = $this->conn->getAll($sql, $fetchmode);182 } 183 184 if ($this->conn->isError($ result)) {185 $this->send_err_mail($ result, $sql);186 } 187 $this->result = $ result;192 $affected = $sth->execute($arrVal); 193 } else { 194 $affected = $sth->execute(); 195 } 196 197 if ($this->conn->isError($affected)) { 198 $this->send_err_mail($affected, $sql); 199 } 200 $this->result = $affected->fetchAll($fetchmode); 188 201 189 202 return $this->result;
Note: See TracChangeset
for help on using the changeset viewer.