本文整理汇总了PHP中Query::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::orderBy方法的具体用法?PHP Query::orderBy怎么用?PHP Query::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::orderBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOrderBy
/**
* @covers flowcode\ceibo\domain\Query::orderBy
*/
public function testOrderBy()
{
$this->object->orderBy("name");
$this->object->orderBy("name", "DESC");
$stmt = $this->object->buildStatement();
$this->assertEquals("SELECT * FROM ovni ORDER BY name ASC, name DESC", $stmt);
}
示例2: index
public function index()
{
$query = new Query();
$query->orderBy('id', 'DESC');
$query->limit(4);
$posts = $query->find('Posts');
$this->render('index.html.twig', array('posts' => $posts));
}
示例3: testOrdering
public function testOrdering()
{
$path = __DIR__ . '/fixtures/datastore/querytest';
$config = new Config($path . '/');
$repo = new Repository('countries', $config);
$query = new Query($repo);
$query->orderBy('capital DESC');
$result = $query->execute();
$this->assertEquals('Croatia', $result->first()->id);
$this->assertEquals('Heard Island and McDonald Islands', $result[$result->count() - 1]->id);
}
示例4: scopePublicLatestReleases
/**
* Get public latest releases with artist name
*
* @param Query $query
* @return Query
*/
public function scopePublicLatestReleases($query)
{
return $query->orderBy('released_at', 'desc')->join('artists', 'artists.id', '=', 'releases.artist_id')->select(['releases.title', 'releases.permalink', 'releases.coverart_thumbnail', 'releases.coverart_alt', 'releases.genre', DB::raw('artists.name as artist_name')])->where('releases.active', true);
}
示例5: scopeLatest
/**
* Se obtienen todos los posts con su categoria y seccion activos
*
* @param Query $query
* @return Query
*/
public function scopeLatest($query)
{
return $query->orderBy('posts.created_at', 'desc')->join('categories', 'categories.id', '=', 'posts.category_id')->select(['posts.id', 'posts.category_id', 'posts.title', 'posts.permalink', 'posts.active', DB::raw('categories.name as category_name'), DB::raw('categories.permalink as category_permalink')]);
}
示例6: Query
<?php
require_once 'autoloader.php';
$query = new Query();
$query->orderBy('id', 'DESC');
$query->limit(2, 4);
$user = $query->isEntity('Users');
var_dump($user);
$user = new Users();
$user->setPseudo('Luke Skywalker');
$user->setAge('26');
$user->setPassword('LoveMySister');
$user->save();
示例7: _sorterQueryObject
/**
* Aplica ordenação em objetos Query.
*
* @param Query $query
* @return Query
* */
private function _sorterQueryObject($query)
{
foreach ($this->_orderByList as $colName => $order) {
$query->orderBy(array($colName => $order));
}
return $query;
}
示例8: testSelectDistinctStatement_Order_By_Array
public function testSelectDistinctStatement_Order_By_Array()
{
$query = new Query("SELECT DISTINCT id, description FROM `test`");
$query->orderBy(array("name", "description", "checksum"));
$this->assertEquals("SELECT DISTINCT id, description FROM `test` ORDER BY `name`, `description`, `checksum`", (string) $query);
}