public function all()
 {
     $model = ReflectionUtils::createNewInstance(static::$forModel);
     $query = Query::getInstance()->select()->from($model->table())->order(Order::desc("id"));
     $resultSet = $this->getDatabase()->query($query)->listResult();
     return new ResultSet($resultSet);
 }
 public function testShouldProduceSelectStatementWithOrderBy()
 {
     $table = "test";
     $sql = Query::getInstance()->select("id")->from($table)->order(Order::desc("id"))->build();
     $expectedSql = "SELECT id FROM {$table} ORDER BY id DESC";
     $this->assertThat($sql, $this->equalTo($expectedSql));
 }
Example #3
0
 /**
  * Add a order by clause to query
  *
  * @param Order $orderBy
  * @return Query
  */
 public function order(Order $orderBy)
 {
     $this->order = $orderBy->toSql();
     return $this;
 }