Exemplo n.º 1
0
 /**
  *  ステートメントの実行
  *
  *  ステートメントを実行して結果値を取得する。<br/>
  *  抽出条件が下記の条件に該当する場合に実行される
  *   - {@link Cascade_DB_SQL_Criteria::TYPE_IS_FIND}
  *
  *  @return  mixed  実行結果
  */
 protected function fetchResultForFind()
 {
     // 結果データを構築
     $result = array();
     $driver = $this->getDriver();
     $primary_key = $this->data_format->getPrimaryKey();
     $fetch_mode = $this->data_format->getFetchMode();
     while ($record = $driver->fetch()) {
         switch ($fetch_mode) {
             case self::FETCH_MODE_NUM:
                 $result[] = array_values($record);
                 break;
             case self::FETCH_MODE_ASSOC:
                 if (NULL !== ($idx = $this->getResultIndex($primary_key, $record))) {
                     $result[$idx] = $record;
                 } else {
                     $result[] = $record;
                 }
                 break;
             default:
                 $ex_msg = 'Unsupported fetch_mode {df, fetch_mode} %s %d';
                 $ex_msg = sprintf($ex_msg, get_class($this->data_format, $fetch_mode));
                 throw new Cascade_Exception_DBException($ex_msg);
         }
     }
     return $result;
 }