Ignore:
Timestamp:
2010/07/26 17:16:59 (14 years ago)
Author:
nanasess
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
Message:
  • MDB2に対応(#564)
    • r18755 のパッチをマージ
    • PEAR::DB を削除
    • 暫定的にインストーラを修正
    • PHPUnit/Framework.php を直接 require するための require.php を追加
    • カレントディレクトリでのテストケース実行をサポート
    • 実装に合わせて README.txt を修正
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/SC_DbConn.php

    r18743 r18763  
    2323 
    2424$current_dir = realpath(dirname(__FILE__)); 
    25 require_once($current_dir . "/../module/DB.php"); 
     25require_once($current_dir . "/../module/MDB2.php"); 
    2626 
    2727$g_arr_objDbConn = array(); 
     
    6161 
    6262        if ($new) { 
    63             $this->conn = DB::connect($this->dsn, $options); 
     63            // TODO singleton の方が良いかも 
     64            $this->conn = MDB2::connect($this->dsn, $options); 
    6465            $g_arr_objDbConn[$this->dsn] = $this->conn; 
    6566 
     67            // TODO MDB2::setCharset() を使った方が良い? 
    6668            if (DB_TYPE == 'mysql') { 
    6769                $g_arr_objDbConn[$this->dsn]->query('SET NAMES utf8'); // FIXME mysql_set_charset を使える環境では、その方が良さそう (2010/03/03 Seasoft 塚田) 
     
    7274        } 
    7375 
     76        $this->conn->setFetchMode(MDB2_FETCHMODE_ASSOC); 
    7477        $this->err_disp = $err_disp; 
    7578        $this->dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
     
    7780 
    7881    // クエリの実行 
    79     function query($n ,$arr = "", $ignore_err = false){ 
     82    function query($n ,$arr = array(), $ignore_err = false){ 
    8083        // mysqlの場合にはビュー表を変換する 
    8184        if (DB_TYPE == "mysql") $n = $this->dbFactory->sfChangeMySQL($n); 
    8285 
     86        $sth = $this->conn->prepare($n); 
    8387        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(); 
    8791        } 
    8892 
     
    96100 
    97101    // 一件のみ取得 
    98     function getOne($n, $arr = ""){ 
     102    function getOne($n, $arr = array()){ 
    99103 
    100104        // mysqlの場合にはビュー表を変換する 
    101105        if (DB_TYPE == "mysql") $n = $this->dbFactory->sfChangeMySQL($n); 
    102106 
     107        $sth = $this->conn->prepare($n); 
    103108        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(); 
    113118        return $this->result; 
    114119    } 
     
    122127     * @return array データを含む1次元配列。失敗した場合に DB_Error オブジェクトを返します。 
    123128     */ 
    124     function getRow($sql, $arrVal = array(), $fetchmode = DB_FETCHMODE_ASSOC) { 
     129    function getRow($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
    125130         
    126131        // mysqlの場合にはビュー表を変換する 
    127132        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); 
    128144         
    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()) { 
    139149 
    140150        // mysqlの場合にはビュー表を変換する 
    141151        if (DB_TYPE == "mysql") $n = $this->dbFactory->sfChangeMySQL($n); 
    142152 
     153        $sth = $this->conn->prepare($n); 
    143154        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); 
    152163        return $this->result; 
    153164    } 
     
    161172     * @return array データを含む2次元配列。失敗した場合に 0 または DB_Error オブジェクトを返します。 
    162173     */ 
    163     function getAll($sql, $arrVal = "", $fetchmode = DB_FETCHMODE_ASSOC) { 
     174    function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
    164175 
    165176        // mysqlの場合にはビュー表を変換する 
     
    176187        } 
    177188 
     189        $sth = $this->conn->prepare($sql); 
     190 
    178191        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); 
    188201 
    189202        return $this->result; 
Note: See TracChangeset for help on using the changeset viewer.