コード例 #1
0
 public function testSimpleCount()
 {
     $qb = QueryBuilder::count('test', '*');
     list($sql, $data) = $qb->resolve();
     $this->assertEquals('SELECT COUNT(*) as count FROM `test`', $sql);
     $this->assertEquals(0, count($data));
 }
コード例 #2
0
ファイル: Model.php プロジェクト: brokencube/automatorm
 public static final function factoryDataCount($where, $table, $dbconnection, array $options = null)
 {
     // Select * from $table where $where
     $build = QueryBuilder::count($table)->where($where);
     if (is_array($options)) {
         // Limit
         if (key_exists('limit', $options) && key_exists('offset', $options)) {
             $build->limit($options['limit'], $options['offset']);
         } elseif (key_exists('limit', $options)) {
             $build->limit($options['limit']);
         }
     }
     $query = new Query($dbconnection);
     list($data) = $query->sql($build)->execute();
     return $data;
 }