Ignore:
Timestamp:
2010/01/10 10:55:55 (16 years ago)
Author:
Seasoft
Message:
  • 使用するフェッチモードの指定を可能とした。
    • getAll#getAll
    • SC_Query#getall
    • SC_Query#select
  • PHP_Document 追加
  • 引数の変数名を分かりやすいものに変更
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/class/SC_DbConn.php

    r18291 r18487  
    147147    } 
    148148 
    149     // SELECT文の実行結果を全て取得 
    150     function getAll($n, $arr = ""){ 
    151  
    152         // mysqlの場合にはビュー表を変換する 
    153         if (DB_TYPE == "mysql") $n = $this->dbFactory->sfChangeMySQL($n); 
    154  
    155         if(PEAR::isError($this->conn)) { 
    156             if(ADMIN_MODE){ 
     149    /** 
     150     * クエリを実行し、全ての行を返す 
     151     * 
     152     * @param string $sql SQL クエリ 
     153     * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。  
     154     * @param integer $fetchmode 使用するフェッチモード。デフォルトは DB_FETCHMODE_ASSOC。 
     155     * @return array データを含む2次元配列。失敗した場合に 0 または DB_Error オブジェクトを返します。 
     156     */ 
     157    function getAll($sql, $arrVal = "", $fetchmode = DB_FETCHMODE_ASSOC) { 
     158 
     159        // mysqlの場合にはビュー表を変換する 
     160        if (DB_TYPE == "mysql") $sql = $this->dbFactory->sfChangeMySQL($sql); 
     161 
     162        // XXX このエラー処理はここで行なうべきなのか疑問。また、戻り値も疑問(なお、変更時はドキュメントも変更を)。 
     163        if (PEAR::isError($this->conn)) { 
     164            if (ADMIN_MODE) { 
    157165                SC_Utils_Ex::sfErrorHeader("DBへの接続に失敗しました。:" . $this->dsn); 
    158             }else{ 
     166            } else { 
    159167                SC_Utils_Ex::sfErrorHeader("DBへの接続に失敗しました。:"); 
    160168            } 
     
    162170        } 
    163171 
    164         if ( $arr ){ 
    165             $result = $this->conn->getAll($n, $arr, DB_FETCHMODE_ASSOC); 
    166         } else { 
    167             $result = $this->conn->getAll($n, DB_FETCHMODE_ASSOC); 
    168         } 
    169  
    170         if ($this->conn->isError($result)){ 
    171             $this->send_err_mail($result, $n); 
     172        if ($arrVal) { // FIXME 判定が曖昧 
     173            $result = $this->conn->getAll($sql, $arrVal, $fetchmode); 
     174        } else { 
     175            $result = $this->conn->getAll($sql, $fetchmode); 
     176        } 
     177 
     178        if ($this->conn->isError($result)) { 
     179            $this->send_err_mail($result, $sql); 
    172180        } 
    173181        $this->result = $result; 
Note: See TracChangeset for help on using the changeset viewer.