コード例 #1
0
ファイル: tablegateway.inc.php プロジェクト: troelskn/pdoext
 protected function executeQuery()
 {
     if ($this->result) {
         return;
     }
     if ($this->page_size) {
         if ($this->db->supportsSqlCalcFoundRows() && is_null($this->custom_count)) {
             $this->setSqlCalcFoundRows();
         }
         $limit = $this->pageSize();
         $offset = max($this->currentPage() - 1, 0) * $this->pageSize();
         $this->setLimit($limit);
         $this->setOffset($offset);
     }
     $result = $this->db->query($this);
     $result->setFetchMode(PDO::FETCH_BOTH);
     if (method_exists($this->gateway, 'load')) {
         $this->result = new pdoext_Resultset($result, $this->gateway);
     } else {
         $this->result = $result;
     }
     if ($this->page_size && is_null($this->custom_count)) {
         if ($this->db->supportsSqlCalcFoundRows()) {
             // MySql specific
             $result = $this->db->query("SELECT FOUND_ROWS()");
             $row = $result->fetch();
             $this->total_count = $row[0];
         } else {
             // fall back on select count(*)
             $this->setLimit(null);
             $this->setOffset(null);
             $q = new pdoext_Query($this);
             $q->addColumn(pdoext_literal('count(*)'), 'total_count');
             $result = $this->db->query($q);
             $row = $result->fetch();
             $this->total_count = $row[0];
             $this->setLimit($limit);
             $this->setOffset($offset);
         }
     }
 }
コード例 #2
0
ファイル: query.test.php プロジェクト: troelskn/pdoext
 function test_select_where_in_array_has_no_side_effects()
 {
     $db = $this->getConnection();
     $q = new pdoext_Query('people');
     $q->addCriterion('first_name', array("John", "Jim"));
     $this->assertSqlEqual($q->toSql($db), $q->toSql($db));
 }