Ignore:
Timestamp:
2013/05/02 18:11:36 (11 years ago)
Author:
h_yoshimoto
Message:

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/SC_Query.php

    r22567 r22796  
    3030 * @version $Id$ 
    3131 */ 
    32 class SC_Query  
    33 { 
     32class SC_Query { 
    3433 
    3534    var $option = ''; 
     
    5049     * @param boolean $new 新規に接続を行うかどうか 
    5150     */ 
    52     function __construct($dsn = '', $force_run = false, $new = false) 
    53     { 
     51    function __construct($dsn = '', $force_run = false, $new = false) { 
    5452 
    5553        if ($dsn == '') { 
     
    10199     * @return SC_Query シングルトンの SC_Query インスタンス 
    102100     */ 
    103     static function getSingletonInstance($dsn = '', $force_run = false, $new = false) 
    104     { 
     101    static function getSingletonInstance($dsn = '', $force_run = false, $new = false) { 
    105102        $objThis = SC_Query_Ex::getPoolInstance($dsn); 
    106103        if (is_null($objThis)) { 
     
    122119     * @return boolean 
    123120     */ 
    124     function isError() 
    125     { 
     121    function isError() { 
    126122        if (PEAR::isError($this->conn)) { 
    127123            return true; 
     
    138134     * @return integer 件数 
    139135     */ 
    140     function count($table, $where = '', $arrWhereVal = array()) 
    141     { 
     136    function count($table, $where = '', $arrWhereVal = array()) { 
    142137        return $this->get('COUNT(*)', $table, $where, $arrWhereVal); 
    143138    } 
     
    151146     * @return boolean 有無 
    152147     */ 
    153     function exists($table, $where = '', $arrWhereVal = array()) 
    154     { 
     148    function exists($table, $where = '', $arrWhereVal = array()) { 
    155149        $sql_inner = $this->getSql('*', $table, $where, $arrWhereVal); 
    156150        $sql = "SELECT CASE WHEN EXISTS($sql_inner) THEN 1 ELSE 0 END"; 
     
    169163     * @return array|null 
    170164     */ 
    171     function select($cols, $from = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
    172     { 
     165    function select($cols, $from = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
    173166        $sqlse = $this->getSql($cols, $from, $where, $arrWhereVal); 
    174167        return $this->getAll($sqlse, $arrWhereVal, $fetchmode); 
     
    181174     * @return string SQL文 
    182175     */ 
    183     function getLastQuery($disp = true) 
    184     { 
     176    function getLastQuery($disp = true) { 
    185177        $sql = $this->conn->last_query; 
    186178        if ($disp) { 
     
    196188     *         失敗した場合は PEAR::Error オブジェクト 
    197189     */ 
    198     function commit() 
    199     { 
     190    function commit() { 
    200191        return $this->conn->commit(); 
    201192    } 
     
    207198     *         失敗した場合は PEAR::Error オブジェクト 
    208199     */ 
    209     function begin() 
    210     { 
     200    function begin() { 
    211201        return $this->conn->beginTransaction(); 
    212202    } 
     
    218208     *         失敗した場合は PEAR::Error オブジェクト 
    219209     */ 
    220     function rollback() 
    221     { 
     210    function rollback() { 
    222211        return $this->conn->rollback(); 
    223212    } 
     
    228217     * @return boolean トランザクションが開始されている場合 true 
    229218     */ 
    230     function inTransaction() 
    231     { 
     219    function inTransaction() { 
    232220        return $this->conn->inTransaction(); 
    233221    } 
     
    240228     * FIXME MDB2::exec() の実装であるべき 
    241229     */ 
    242     function exec($str, $arrVal = array()) 
    243     { 
     230    function exec($str, $arrVal = array()) { 
    244231        return $this->query($str, $arrVal); 
    245232    } 
     
    254241     * @return boolean 結果 
    255242     */ 
    256     function doCallbackAll($cbFunc, $sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
    257     { 
     243    function doCallbackAll($cbFunc, $sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
    258244 
    259245        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    287273     * @return array データを含む2次元配列。失敗した場合に 0 または DB_Error オブジェクトを返します。 
    288274     */ 
    289     function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
    290     { 
     275    function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
    291276 
    292277        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    321306     * @return string 構築済みの SELECT 文 
    322307     */ 
    323     function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) 
    324     { 
     308    function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) { 
    325309        $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
    326310 
     
    358342     * @return SC_Query 自分自身のインスタンス 
    359343     */ 
    360     function setOption($str) 
    361     { 
     344    function setOption($str) { 
    362345        $this->option = $str; 
    363346        return $this; 
     
    373356     * @return SC_Query 自分自身のインスタンス 
    374357     */ 
    375     function setLimitOffset($limit, $offset = 0) 
    376     { 
     358    function setLimitOffset($limit, $offset = 0) { 
    377359        if (is_numeric($limit) && is_numeric($offset)) { 
    378360            $this->conn->setLimit($limit, $offset); 
     
    389371     * @return SC_Query 自分自身のインスタンス 
    390372     */ 
    391     function setGroupBy($str) 
    392     { 
     373    function setGroupBy($str) { 
    393374        if (strlen($str) == 0) { 
    394375            $this->groupby = ''; 
     
    407388     * @return SC_Query 自分自身のインスタンス 
    408389     */ 
    409     function andWhere($str) 
    410     { 
     390    function andWhere($str) { 
    411391        if ($this->where != '') { 
    412392            $this->where .= ' AND ' . $str; 
     
    425405     * @return SC_Query 自分自身のインスタンス 
    426406     */ 
    427     function orWhere($str) 
    428     { 
     407    function orWhere($str) { 
    429408        if ($this->where != '') { 
    430409            $this->where .= ' OR ' . $str; 
     
    444423     * @return SC_Query 自分自身のインスタンス 
    445424     */ 
    446     function setWhere($where = '', $arrWhereVal = array()) 
    447     { 
     425    function setWhere($where = '', $arrWhereVal = array()) { 
    448426        $this->where = $where; 
    449427        $this->arrWhereVal = $arrWhereVal; 
     
    459437     * @return SC_Query 自分自身のインスタンス 
    460438     */ 
    461     function setOrder($str) 
    462     { 
     439    function setOrder($str) { 
    463440        if (strlen($str) == 0) { 
    464441            $this->order = ''; 
     
    477454     * @return SC_Query 自分自身のインスタンス 
    478455     */ 
    479     function setLimit($limit) 
    480     { 
     456    function setLimit($limit) { 
    481457        if (is_numeric($limit)) { 
    482458            $this->conn->setLimit($limit); 
     
    493469     * @return SC_Query 自分自身のインスタンス 
    494470     */ 
    495     function setOffset($offset) 
    496     { 
     471    function setOffset($offset) { 
    497472        if (is_numeric($offset)) { 
    498473            $this->conn->setLimit($this->conn->limit, $offset); 
     
    512487     * @return integer|DB_Error|boolean 挿入件数またはエラー(DB_Error, false) 
    513488     */ 
    514     function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $from = '', $arrFromVal = array()) 
    515     { 
     489    function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $from = '', $arrFromVal = array()) { 
    516490        $strcol = ''; 
    517491        $strval = ''; 
     
    570544     * @return 
    571545     */ 
    572     function update($table, $arrVal, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) 
    573     { 
     546    function update($table, $arrVal, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) { 
    574547        $arrCol = array(); 
    575548        $arrValForQuery = array(); 
     
    626599     * @return integer MAX文の実行結果 
    627600     */ 
    628     function max($col, $table, $where = '', $arrWhereVal = array()) 
    629     { 
     601    function max($col, $table, $where = '', $arrWhereVal = array()) { 
    630602        $ret = $this->get("MAX($col)", $table, $where, $arrWhereVal); 
    631603        return $ret; 
     
    641613     * @return integer MIN文の実行結果 
    642614     */ 
    643     function min($col, $table, $where = '', $arrWhereVal = array()) 
    644     { 
     615    function min($col, $table, $where = '', $arrWhereVal = array()) { 
    645616        $ret = $this->get("MIN($col)", $table, $where, $arrWhereVal); 
    646617        return $ret; 
     
    656627     * @return mixed SQL の実行結果 
    657628     */ 
    658     function get($col, $table = '', $where = '', $arrWhereVal = array()) 
    659     { 
     629    function get($col, $table = '', $where = '', $arrWhereVal = array()) { 
    660630        $sqlse = $this->getSql($col, $table, $where, $arrWhereVal); 
    661631        // SQL文の実行 
     
    671641     * @return mixed SQL の実行結果 
    672642     */ 
    673     function getOne($sql, $arrVal = array()) 
    674     { 
     643    function getOne($sql, $arrVal = array()) { 
    675644 
    676645        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    705674     * @return array array('カラム名' => '値', ...)の連想配列 
    706675     */ 
    707     function getRow($col, $table = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
    708     { 
     676    function getRow($col, $table = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
    709677 
    710678        $sql = $this->getSql($col, $table, $where, $arrWhereVal); 
     
    739707     * @return array SQL の実行結果の配列 
    740708     */ 
    741     function getCol($col, $table = '', $where = '', $arrWhereVal = array()) 
    742     { 
     709    function getCol($col, $table = '', $where = '', $arrWhereVal = array()) { 
    743710        $sql = $this->getSql($col, $table, $where, $arrWhereVal); 
    744711        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    771738     * @return 
    772739     */ 
    773     function delete($table, $where = '', $arrWhereVal = array()) 
    774     { 
     740    function delete($table, $where = '', $arrWhereVal = array()) { 
    775741        if (strlen($where) <= 0) { 
    776742            $sqlde = "DELETE FROM $table"; 
     
    788754     * @param integer 次のシーケンス値 
    789755     */ 
    790     function nextVal($seq_name) 
    791     { 
     756    function nextVal($seq_name) { 
    792757        return $this->conn->nextID($seq_name); 
    793758    } 
     
    799764     * @return integer 現在のシーケンス値 
    800765     */ 
    801     function currVal($seq_name) 
    802     { 
     766    function currVal($seq_name) { 
    803767        return $this->conn->currID($seq_name); 
    804768    } 
     
    811775     * @return MDB2_OK 
    812776     */ 
    813     function setVal($seq_name, $start) 
    814     { 
     777    function setVal($seq_name, $start) { 
    815778        $objManager =& $this->conn->loadModule('Manager'); 
    816779 
     
    840803     * @return array SQL の実行結果の配列 
    841804     */ 
    842     function query($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) 
    843     { 
     805    function query($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) { 
    844806 
    845807        $n = $this->dbFactory->sfChangeMySQL($n); 
     
    866828     * @return array シーケンス名の配列 
    867829     */ 
    868     function listSequences() 
    869     { 
     830    function listSequences() { 
    870831        $objManager =& $this->conn->loadModule('Manager'); 
    871832        return $objManager->listSequences(); 
     
    877838     * @return array テーブル名の配列 
    878839     */ 
    879     function listTables() 
    880     { 
     840    function listTables() { 
    881841        return $this->dbFactory->listTables($this); 
    882842    } 
     
    888848     * @return array 指定のテーブルのカラム名の配列 
    889849     */ 
    890     function listTableFields($table) 
    891     { 
     850    function listTableFields($table) { 
    892851        $objManager =& $this->conn->loadModule('Manager'); 
    893852        return $objManager->listTableFields($table); 
     
    900859     * @return array 指定のテーブルのインデックス一覧 
    901860     */ 
    902     function listTableIndexes($table) 
    903     { 
     861    function listTableIndexes($table) { 
    904862        $objManager =& $this->conn->loadModule('Manager'); 
    905863        return $objManager->listTableIndexes($table); 
     
    914872     *               MySQLのtext型フィールドを指定する場合は $definition['length'] = 'text_field(NNN)' が必要 
    915873     */ 
    916     function createIndex($table, $name, $definition) 
    917     { 
     874    function createIndex($table, $name, $definition) { 
    918875        $definition = $this->dbFactory->sfGetCreateIndexDefinition($table, $name, $definition); 
    919876        $objManager =& $this->conn->loadModule('Manager'); 
     
    927884     * @param string $name インデックス名 
    928885     */ 
    929     function dropIndex($table, $name) 
    930     { 
     886    function dropIndex($table, $name) { 
    931887        $objManager =& $this->conn->loadModule('Manager'); 
    932888        return $objManager->dropIndex($table, $name); 
     
    939895     * @return array テーブル情報の配列 
    940896     */ 
    941     function getTableInfo($table) 
    942     { 
     897    function getTableInfo($table) { 
    943898        $objManager =& $this->conn->loadModule('Reverse'); 
    944899        return $objManager->tableInfo($table, NULL); 
     
    956911     * @return string クォートされた文字列 
    957912     */ 
    958     function quote($val) 
    959     { 
     913    function quote($val) { 
    960914        return $this->conn->quote($val); 
    961915    } 
     
    968922     * @return array テーブルに存在する列のみ抽出した連想配列 
    969923     */ 
    970     function extractOnlyColsOf($table, $arrParams) 
    971     { 
     924    function extractOnlyColsOf($table, $arrParams) { 
    972925        $arrCols = $this->listTableFields($table); 
    973926        $arrResults = array(); 
     
    989942     * @return MDB2_Statement_Common プリペアドステートメントインスタンス 
    990943     */ 
    991     function prepare($sql, $types = null, $result_types = MDB2_PREPARE_RESULT) 
    992     { 
     944    function prepare($sql, $types = null, $result_types = MDB2_PREPARE_RESULT) { 
    993945        $sth =& $this->conn->prepare($sql, $types, $result_types); 
    994946        if (PEAR::isError($sth)) { 
     
    1007959     * @return MDB2_Result 結果セットのインスタンス 
    1008960     */ 
    1009     function execute(&$sth, $arrVal = array()) 
    1010     { 
     961    function execute(&$sth, $arrVal = array()) { 
    1011962 
    1012963        $arrStartInfo =& $this->lfStartDbTraceLog($sth, $arrVal); 
     
    1034985     * @return string トレースしたエラー文字列 
    1035986     */ 
    1036     function traceError($error, $sql = '', $arrVal = false) 
    1037     { 
     987    function traceError($error, $sql = '', $arrVal = false) { 
    1038988        $err = "SQL: [$sql]\n"; 
    1039989        if ($arrVal !== false) { 
     
    10521002     * エラー処理 
    10531003     */ 
    1054     function error($msg) 
    1055     { 
     1004    function error($msg) { 
    10561005        $msg = "DB処理でエラーが発生しました。\n" . $msg; 
    10571006        if (!$this->force_run) { 
     
    10721021     * @return array 実行結果の配列 
    10731022     */ 
    1074     function getQueryDefsFields($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) 
    1075     { 
     1023    function getQueryDefsFields($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) { 
    10761024 
    10771025        $n = $this->dbFactory->sfChangeMySQL($n); 
     
    11001048     * @return void 
    11011049     */ 
    1102     private function lfStartDbTraceLog(&$objSth, &$arrVal) 
    1103     { 
     1050    private function lfStartDbTraceLog(&$objSth, &$arrVal) { 
    11041051        if (!defined('SQL_QUERY_LOG_MODE') || SQL_QUERY_LOG_MODE === 0) { 
    11051052            return; 
     
    11361083     * @return void 
    11371084     */ 
    1138     private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) 
    1139     { 
     1085    private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) { 
    11401086        if (!defined('SQL_QUERY_LOG_MODE') || SQL_QUERY_LOG_MODE === 0) { 
    11411087            return; 
     
    11681114     * @return SC_Query プールしたインスタンス 
    11691115     */ 
    1170     static function setPoolInstance(&$objThis, $dsn = '') 
    1171     { 
     1116    static function setPoolInstance(&$objThis, $dsn = '') { 
    11721117        $key_str = serialize($dsn); 
    11731118        return SC_Query_Ex::$arrPoolInstance[$key_str] = $objThis; 
     
    11801125     * @return SC_Query|null 
    11811126     */ 
    1182     static function getPoolInstance($dsn = '') 
    1183     { 
     1127    static function getPoolInstance($dsn = '') { 
    11841128        $key_str = serialize($dsn); 
    11851129        if (isset(SC_Query_Ex::$arrPoolInstance[$key_str])) { 
Note: See TracChangeset for help on using the changeset viewer.