_run() protected method

Execute the SELECT query that has been built up by chaining methods on this class. Return an array of rows as associative arrays.
protected _run ( )
コード例 #1
0
 /**
  * Execute the SELECT query that has been built up by chaining methods
  * on this class. Return an array of rows as associative arrays.
  */
 protected function _run()
 {
     // allow parent method to run
     if (!$this->cnt_query) {
         // need a way to make sure this is set
         if ($this->_is_raw_query) {
             if (is_array($this->_raw_parameters)) {
                 foreach ($this->_raw_parameters as $k => $v) {
                     if (!is_numeric($v)) {
                         $v = '"' . $v . '"';
                     }
                     $this->_raw_query = str_replace(':' . $k, $v, $this->_raw_query);
                 }
             }
         }
         return parent::_run();
     }
     // we are not caching the COUNT - @todo - implement caching
     $query = $this->_build_select();
     parent::_execute($query, $this->_values, $this->_connection_name);
     $statement = parent::get_last_statement();
     $rows = array();
     while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
         $rows[] = $row;
     }
     // reset Idiorm bound values
     $this->_values = array();
     return $rows;
 }