select() публичный статический Метод

public static select ( $selectColumns = null )
Пример #1
0
 /**
  * @group non-sqlite3
  * @test
  */
 public function selectShouldNotLockForUpdateByDefault()
 {
     // when
     $query = Query::select();
     // then
     $this->assertFalse($query->lockForUpdate);
 }
Пример #2
0
 /**
  * @test
  */
 public function shouldHandleSubQueries()
 {
     //given
     Product::create(array('name' => 'prod1', 'description' => 'd'));
     Product::create(array('name' => 'prod1', 'description' => 'd'));
     Product::create(array('name' => 'prod2', 'description' => 'd'));
     $query = Query::select(array('count(*) AS c'))->from(Query::select(array('name', 'count(*) c'))->from('products')->groupBy('name')->where(array('description' => 'd')), 'sub')->where(array('c' => 2));
     $executor = QueryExecutor::prepare(Db::getInstance(), $query);
     //when
     $result = $executor->fetch();
     //then
     $this->assertEquals(array('c' => 1), $result);
 }
Пример #3
0
 /**
  * @test
  */
 public function shouldReturnGroupBy()
 {
     // given
     $query = Query::select(array('category', 'count(*)'))->table('products')->groupBy('category');
     // when
     $sql = $this->_dialect->buildQuery($query);
     // then
     $this->assertEquals('SELECT category, count(*) FROM products GROUP BY category', $sql);
 }