Ignore:
Timestamp:
2013/02/18 19:09:54 (11 years ago)
Author:
shutta
Message:

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

File:
1 edited

Legend:

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

    r22206 r22567  
    3030 * @version $Id$ 
    3131 */ 
    32 class SC_Query { 
     32class SC_Query  
     33{ 
    3334 
    3435    var $option = ''; 
     
    4950     * @param boolean $new 新規に接続を行うかどうか 
    5051     */ 
    51     function __construct($dsn = '', $force_run = false, $new = false) { 
     52    function __construct($dsn = '', $force_run = false, $new = false) 
     53    { 
    5254 
    5355        if ($dsn == '') { 
     
    99101     * @return SC_Query シングルトンの SC_Query インスタンス 
    100102     */ 
    101     static function getSingletonInstance($dsn = '', $force_run = false, $new = false) { 
     103    static function getSingletonInstance($dsn = '', $force_run = false, $new = false) 
     104    { 
    102105        $objThis = SC_Query_Ex::getPoolInstance($dsn); 
    103106        if (is_null($objThis)) { 
     
    119122     * @return boolean 
    120123     */ 
    121     function isError() { 
     124    function isError() 
     125    { 
    122126        if (PEAR::isError($this->conn)) { 
    123127            return true; 
     
    134138     * @return integer 件数 
    135139     */ 
    136     function count($table, $where = '', $arrWhereVal = array()) { 
     140    function count($table, $where = '', $arrWhereVal = array()) 
     141    { 
    137142        return $this->get('COUNT(*)', $table, $where, $arrWhereVal); 
    138143    } 
     
    146151     * @return boolean 有無 
    147152     */ 
    148     function exists($table, $where = '', $arrWhereVal = array()) { 
     153    function exists($table, $where = '', $arrWhereVal = array()) 
     154    { 
    149155        $sql_inner = $this->getSql('*', $table, $where, $arrWhereVal); 
    150156        $sql = "SELECT CASE WHEN EXISTS($sql_inner) THEN 1 ELSE 0 END"; 
     
    163169     * @return array|null 
    164170     */ 
    165     function select($cols, $from = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
     171    function select($cols, $from = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
     172    { 
    166173        $sqlse = $this->getSql($cols, $from, $where, $arrWhereVal); 
    167174        return $this->getAll($sqlse, $arrWhereVal, $fetchmode); 
     
    174181     * @return string SQL文 
    175182     */ 
    176     function getLastQuery($disp = true) { 
     183    function getLastQuery($disp = true) 
     184    { 
    177185        $sql = $this->conn->last_query; 
    178186        if ($disp) { 
     
    188196     *         失敗した場合は PEAR::Error オブジェクト 
    189197     */ 
    190     function commit() { 
     198    function commit() 
     199    { 
    191200        return $this->conn->commit(); 
    192201    } 
     
    198207     *         失敗した場合は PEAR::Error オブジェクト 
    199208     */ 
    200     function begin() { 
     209    function begin() 
     210    { 
    201211        return $this->conn->beginTransaction(); 
    202212    } 
     
    208218     *         失敗した場合は PEAR::Error オブジェクト 
    209219     */ 
    210     function rollback() { 
     220    function rollback() 
     221    { 
    211222        return $this->conn->rollback(); 
    212223    } 
     
    217228     * @return boolean トランザクションが開始されている場合 true 
    218229     */ 
    219     function inTransaction() { 
     230    function inTransaction() 
     231    { 
    220232        return $this->conn->inTransaction(); 
    221233    } 
     
    228240     * FIXME MDB2::exec() の実装であるべき 
    229241     */ 
    230     function exec($str, $arrVal = array()) { 
     242    function exec($str, $arrVal = array()) 
     243    { 
    231244        return $this->query($str, $arrVal); 
    232245    } 
     
    241254     * @return boolean 結果 
    242255     */ 
    243     function doCallbackAll($cbFunc, $sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
     256    function doCallbackAll($cbFunc, $sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
     257    { 
    244258 
    245259        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    273287     * @return array データを含む2次元配列。失敗した場合に 0 または DB_Error オブジェクトを返します。 
    274288     */ 
    275     function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
     289    function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
     290    { 
    276291 
    277292        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    306321     * @return string 構築済みの SELECT 文 
    307322     */ 
    308     function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) { 
     323    function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) 
     324    { 
    309325        $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
    310326 
     
    342358     * @return SC_Query 自分自身のインスタンス 
    343359     */ 
    344     function setOption($str) { 
     360    function setOption($str) 
     361    { 
    345362        $this->option = $str; 
    346363        return $this; 
     
    356373     * @return SC_Query 自分自身のインスタンス 
    357374     */ 
    358     function setLimitOffset($limit, $offset = 0) { 
     375    function setLimitOffset($limit, $offset = 0) 
     376    { 
    359377        if (is_numeric($limit) && is_numeric($offset)) { 
    360378            $this->conn->setLimit($limit, $offset); 
     
    371389     * @return SC_Query 自分自身のインスタンス 
    372390     */ 
    373     function setGroupBy($str) { 
     391    function setGroupBy($str) 
     392    { 
    374393        if (strlen($str) == 0) { 
    375394            $this->groupby = ''; 
     
    388407     * @return SC_Query 自分自身のインスタンス 
    389408     */ 
    390     function andWhere($str) { 
     409    function andWhere($str) 
     410    { 
    391411        if ($this->where != '') { 
    392412            $this->where .= ' AND ' . $str; 
     
    405425     * @return SC_Query 自分自身のインスタンス 
    406426     */ 
    407     function orWhere($str) { 
     427    function orWhere($str) 
     428    { 
    408429        if ($this->where != '') { 
    409430            $this->where .= ' OR ' . $str; 
     
    423444     * @return SC_Query 自分自身のインスタンス 
    424445     */ 
    425     function setWhere($where = '', $arrWhereVal = array()) { 
     446    function setWhere($where = '', $arrWhereVal = array()) 
     447    { 
    426448        $this->where = $where; 
    427449        $this->arrWhereVal = $arrWhereVal; 
     
    437459     * @return SC_Query 自分自身のインスタンス 
    438460     */ 
    439     function setOrder($str) { 
     461    function setOrder($str) 
     462    { 
    440463        if (strlen($str) == 0) { 
    441464            $this->order = ''; 
     
    454477     * @return SC_Query 自分自身のインスタンス 
    455478     */ 
    456     function setLimit($limit) { 
     479    function setLimit($limit) 
     480    { 
    457481        if (is_numeric($limit)) { 
    458482            $this->conn->setLimit($limit); 
     
    469493     * @return SC_Query 自分自身のインスタンス 
    470494     */ 
    471     function setOffset($offset) { 
     495    function setOffset($offset) 
     496    { 
    472497        if (is_numeric($offset)) { 
    473498            $this->conn->setLimit($this->conn->limit, $offset); 
     
    487512     * @return integer|DB_Error|boolean 挿入件数またはエラー(DB_Error, false) 
    488513     */ 
    489     function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $from = '', $arrFromVal = array()) { 
     514    function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $from = '', $arrFromVal = array()) 
     515    { 
    490516        $strcol = ''; 
    491517        $strval = ''; 
     
    544570     * @return 
    545571     */ 
    546     function update($table, $arrVal, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) { 
     572    function update($table, $arrVal, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) 
     573    { 
    547574        $arrCol = array(); 
    548575        $arrValForQuery = array(); 
     
    599626     * @return integer MAX文の実行結果 
    600627     */ 
    601     function max($col, $table, $where = '', $arrWhereVal = array()) { 
     628    function max($col, $table, $where = '', $arrWhereVal = array()) 
     629    { 
    602630        $ret = $this->get("MAX($col)", $table, $where, $arrWhereVal); 
    603631        return $ret; 
     
    613641     * @return integer MIN文の実行結果 
    614642     */ 
    615     function min($col, $table, $where = '', $arrWhereVal = array()) { 
     643    function min($col, $table, $where = '', $arrWhereVal = array()) 
     644    { 
    616645        $ret = $this->get("MIN($col)", $table, $where, $arrWhereVal); 
    617646        return $ret; 
     
    627656     * @return mixed SQL の実行結果 
    628657     */ 
    629     function get($col, $table = '', $where = '', $arrWhereVal = array()) { 
     658    function get($col, $table = '', $where = '', $arrWhereVal = array()) 
     659    { 
    630660        $sqlse = $this->getSql($col, $table, $where, $arrWhereVal); 
    631661        // SQL文の実行 
     
    641671     * @return mixed SQL の実行結果 
    642672     */ 
    643     function getOne($sql, $arrVal = array()) { 
     673    function getOne($sql, $arrVal = array()) 
     674    { 
    644675 
    645676        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    674705     * @return array array('カラム名' => '値', ...)の連想配列 
    675706     */ 
    676     function getRow($col, $table = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 
     707    function getRow($col, $table = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) 
     708    { 
    677709 
    678710        $sql = $this->getSql($col, $table, $where, $arrWhereVal); 
     
    707739     * @return array SQL の実行結果の配列 
    708740     */ 
    709     function getCol($col, $table = '', $where = '', $arrWhereVal = array()) { 
     741    function getCol($col, $table = '', $where = '', $arrWhereVal = array()) 
     742    { 
    710743        $sql = $this->getSql($col, $table, $where, $arrWhereVal); 
    711744        $sql = $this->dbFactory->sfChangeMySQL($sql); 
     
    738771     * @return 
    739772     */ 
    740     function delete($table, $where = '', $arrWhereVal = array()) { 
     773    function delete($table, $where = '', $arrWhereVal = array()) 
     774    { 
    741775        if (strlen($where) <= 0) { 
    742776            $sqlde = "DELETE FROM $table"; 
     
    754788     * @param integer 次のシーケンス値 
    755789     */ 
    756     function nextVal($seq_name) { 
     790    function nextVal($seq_name) 
     791    { 
    757792        return $this->conn->nextID($seq_name); 
    758793    } 
     
    764799     * @return integer 現在のシーケンス値 
    765800     */ 
    766     function currVal($seq_name) { 
     801    function currVal($seq_name) 
     802    { 
    767803        return $this->conn->currID($seq_name); 
    768804    } 
     
    775811     * @return MDB2_OK 
    776812     */ 
    777     function setVal($seq_name, $start) { 
     813    function setVal($seq_name, $start) 
     814    { 
    778815        $objManager =& $this->conn->loadModule('Manager'); 
    779816 
     
    803840     * @return array SQL の実行結果の配列 
    804841     */ 
    805     function query($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) { 
     842    function query($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) 
     843    { 
    806844 
    807845        $n = $this->dbFactory->sfChangeMySQL($n); 
     
    828866     * @return array シーケンス名の配列 
    829867     */ 
    830     function listSequences() { 
     868    function listSequences() 
     869    { 
    831870        $objManager =& $this->conn->loadModule('Manager'); 
    832871        return $objManager->listSequences(); 
     
    838877     * @return array テーブル名の配列 
    839878     */ 
    840     function listTables() { 
     879    function listTables() 
     880    { 
    841881        return $this->dbFactory->listTables($this); 
    842882    } 
     
    848888     * @return array 指定のテーブルのカラム名の配列 
    849889     */ 
    850     function listTableFields($table) { 
     890    function listTableFields($table) 
     891    { 
    851892        $objManager =& $this->conn->loadModule('Manager'); 
    852893        return $objManager->listTableFields($table); 
     
    859900     * @return array 指定のテーブルのインデックス一覧 
    860901     */ 
    861     function listTableIndexes($table) { 
     902    function listTableIndexes($table) 
     903    { 
    862904        $objManager =& $this->conn->loadModule('Manager'); 
    863905        return $objManager->listTableIndexes($table); 
     
    872914     *               MySQLのtext型フィールドを指定する場合は $definition['length'] = 'text_field(NNN)' が必要 
    873915     */ 
    874     function createIndex($table, $name, $definition) { 
     916    function createIndex($table, $name, $definition) 
     917    { 
    875918        $definition = $this->dbFactory->sfGetCreateIndexDefinition($table, $name, $definition); 
    876919        $objManager =& $this->conn->loadModule('Manager'); 
     
    884927     * @param string $name インデックス名 
    885928     */ 
    886     function dropIndex($table, $name) { 
     929    function dropIndex($table, $name) 
     930    { 
    887931        $objManager =& $this->conn->loadModule('Manager'); 
    888932        return $objManager->dropIndex($table, $name); 
     
    895939     * @return array テーブル情報の配列 
    896940     */ 
    897     function getTableInfo($table) { 
     941    function getTableInfo($table) 
     942    { 
    898943        $objManager =& $this->conn->loadModule('Reverse'); 
    899944        return $objManager->tableInfo($table, NULL); 
     
    911956     * @return string クォートされた文字列 
    912957     */ 
    913     function quote($val) { 
     958    function quote($val) 
     959    { 
    914960        return $this->conn->quote($val); 
    915961    } 
     
    922968     * @return array テーブルに存在する列のみ抽出した連想配列 
    923969     */ 
    924     function extractOnlyColsOf($table, $arrParams) { 
     970    function extractOnlyColsOf($table, $arrParams) 
     971    { 
    925972        $arrCols = $this->listTableFields($table); 
    926973        $arrResults = array(); 
     
    942989     * @return MDB2_Statement_Common プリペアドステートメントインスタンス 
    943990     */ 
    944     function prepare($sql, $types = null, $result_types = MDB2_PREPARE_RESULT) { 
     991    function prepare($sql, $types = null, $result_types = MDB2_PREPARE_RESULT) 
     992    { 
    945993        $sth =& $this->conn->prepare($sql, $types, $result_types); 
    946994        if (PEAR::isError($sth)) { 
     
    9591007     * @return MDB2_Result 結果セットのインスタンス 
    9601008     */ 
    961     function execute(&$sth, $arrVal = array()) { 
     1009    function execute(&$sth, $arrVal = array()) 
     1010    { 
    9621011 
    9631012        $arrStartInfo =& $this->lfStartDbTraceLog($sth, $arrVal); 
     
    9851034     * @return string トレースしたエラー文字列 
    9861035     */ 
    987     function traceError($error, $sql = '', $arrVal = false) { 
     1036    function traceError($error, $sql = '', $arrVal = false) 
     1037    { 
    9881038        $err = "SQL: [$sql]\n"; 
    9891039        if ($arrVal !== false) { 
     
    10021052     * エラー処理 
    10031053     */ 
    1004     function error($msg) { 
     1054    function error($msg) 
     1055    { 
    10051056        $msg = "DB処理でエラーが発生しました。\n" . $msg; 
    10061057        if (!$this->force_run) { 
     
    10211072     * @return array 実行結果の配列 
    10221073     */ 
    1023     function getQueryDefsFields($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) { 
     1074    function getQueryDefsFields($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) 
     1075    { 
    10241076 
    10251077        $n = $this->dbFactory->sfChangeMySQL($n); 
     
    10481100     * @return void 
    10491101     */ 
    1050     private function lfStartDbTraceLog(&$objSth, &$arrVal) { 
     1102    private function lfStartDbTraceLog(&$objSth, &$arrVal) 
     1103    { 
    10511104        if (!defined('SQL_QUERY_LOG_MODE') || SQL_QUERY_LOG_MODE === 0) { 
    10521105            return; 
     
    10831136     * @return void 
    10841137     */ 
    1085     private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) { 
     1138    private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) 
     1139    { 
    10861140        if (!defined('SQL_QUERY_LOG_MODE') || SQL_QUERY_LOG_MODE === 0) { 
    10871141            return; 
     
    11141168     * @return SC_Query プールしたインスタンス 
    11151169     */ 
    1116     static function setPoolInstance(&$objThis, $dsn = '') { 
     1170    static function setPoolInstance(&$objThis, $dsn = '') 
     1171    { 
    11171172        $key_str = serialize($dsn); 
    11181173        return SC_Query_Ex::$arrPoolInstance[$key_str] = $objThis; 
     
    11251180     * @return SC_Query|null 
    11261181     */ 
    1127     static function getPoolInstance($dsn = '') { 
     1182    static function getPoolInstance($dsn = '') 
     1183    { 
    11281184        $key_str = serialize($dsn); 
    11291185        if (isset(SC_Query_Ex::$arrPoolInstance[$key_str])) { 
Note: See TracChangeset for help on using the changeset viewer.