本文整理汇总了PHP中QueryBuilder::order方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::order方法的具体用法?PHP QueryBuilder::order怎么用?PHP QueryBuilder::order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::order方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOrder4
/**
* Generated from @assert order('id ASCD')->text() [==] "".
*
* @covers Kotchasan\Database\QueryBuilder::order
*/
public function testOrder4()
{
$this->assertEquals("", $this->object->order('id ASCD')->text());
}
示例2: while
$total_qb = clone $qb;
$total_qb->select('COUNT(*)');
$statement = $db->query($total_qb->getQuery());
while ($row = $statement->fetch()) {
$total_results = $row[0];
}
}
$_SESSION['sql_conditions_hash'] = $sql_hash;
$_SESSION['last_query_total_results'] = $total_results;
$peregrine->refreshCage('session');
} else {
$total_results = $peregrine->session->getInt('last_query_total_results');
}
// Order by
if (defined('DEFAULT_ORDER_BY') && DEFAULT_ORDER_BY != '') {
$qb->order(DEFAULT_ORDER_BY);
}
$per_page = $peregrine->post->getInt('per_page');
// Try to ensure it's somewhat sensible
if ($per_page <= 0 || $per_page > 10000) {
$per_page = 25;
}
$response = array('results' => false, 'total_results' => $total_results, 'per_page' => $per_page, 'pages' => $total_results > 0 ? ceil($total_results / $per_page) : 0, 'curr_page' => $peregrine->post->getInt('curr_page'), 'sql_hash' => $sql_hash, 'session_hash' => $peregrine->session->getAlnum('sql_conditions_hash'));
// Limit
$offset = ($response['curr_page'] - 1) * $response['per_page'];
$qb->limit($offset, $response['per_page']);
// Merge sql
$sql = $qb->getQuery();
if (defined('WEB_UI_DEBUG') && WEB_UI_DEBUG) {
print $sql;
exit;