本文整理汇总了PHP中QueryBuilder::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::orderBy方法的具体用法?PHP QueryBuilder::orderBy怎么用?PHP QueryBuilder::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::orderBy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doOrdering
/**
* Datatable ordering
*
* @return null
*/
public function doOrdering()
{
if ($this->isOrderable()) {
for ($i = 0, $c = count($this->input['order']); $i < $c; $i++) {
$order_col = (int) $this->input['order'][$i]['column'];
$order_dir = $this->input['order'][$i]['dir'];
if (!$this->isColumnOrderable($this->input['columns'][$order_col])) {
continue;
}
$column = $this->getOrderColumnName($order_col);
$this->query->orderBy($column, $order_dir);
}
}
}
示例2: sort
/**
* Sort data
* @param Sorting $sorting
* @return static
*/
public function sort(Sorting $sorting)
{
if (is_callable($sorting->getSortCallback())) {
call_user_func($sorting->getSortCallback(), $this->data_source, $sorting->getSort());
return $this;
}
$sort = $sorting->getSort();
if (!empty($sort)) {
foreach ($sort as $column => $order) {
$this->data_source = $this->data_source->orderBy($column, $order);
}
} else {
/**
* Has the statement already a order by clause?
*/
$order = $this->data_source->getQueryBuilder()->getClause('order');
if (ArraysHelper::testEmpty($order)) {
$this->data_source = $this->data_source->orderBy($this->primary_key);
}
}
return $this;
}
示例3: getChatSessionsLog
public function getChatSessionsLog(MysqlPager $pager = null, $myUserId = null, $cacheMinutes = 0)
{
$sessions = array();
$qb = new QueryBuilder();
$qb->select(new Field("*", "chat_sess_log"))->from(Tbl::get('TBL_CHAT_SESSIONS_LOG'), "chat_sess_log");
if ($myUserId !== null) {
$orClause = new Orx();
$orClause->add($qb->expr()->equal(new Field("user1_id", "chat_sess_log"), $myUserId));
$orClause->add($qb->expr()->equal(new Field("user2_id", "chat_sess_log"), $myUserId));
$qb->andWhere($orClause);
}
$qb->orderBy(new Field("datetime", "chat_sess_log"), MySqlDatabase::ORDER_DESC);
$sqlQuery = $qb->getSQL();
if ($pager !== null) {
$this->query = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
} else {
$this->query->exec($sqlQuery, $cacheMinutes);
}
if ($this->query->countRecords()) {
while (($sesLogRow = $this->query->fetchRecord()) != null) {
$chatSession = new ChatSessionLog();
$chatSession->user1 = ChatUser::getObject($sesLogRow['user1_id']);
$chatSession->user2 = ChatUser::getObject($sesLogRow['user2_id']);
$chatSession->id = $sesLogRow['id'];
$chatSession->closedDate = $sesLogRow['datetime'];
array_push($sessions, $chatSession);
}
}
return $sessions;
}
示例4: mergeOrderByInto
/**
* Merge this QueryBuilder's ORDER BY into the given QueryBuilder.
*
* @param QueryBuilder $QueryBuilder to merge into
* @return QueryBuilder
*/
public function mergeOrderByInto(QueryBuilder $QueryBuilder)
{
foreach ($this->orderBy as $currentOrderBy) {
$QueryBuilder->orderBy($currentOrderBy['column'], $currentOrderBy['order']);
}
return $QueryBuilder;
}
示例5: search
/**
* Search in alyun opensearch
* @param string $keyword
* @param array $indexArr
* @param array $postTypeArr
* @param integer $cntPerpage
* @param integer $pageNumber
* @return array|mixed
*/
public function search($vars, $keywors, $kwtype, $searchtype)
{
$options = $this->options;
$search_obj = new \CloudsearchSearch($this->client);
$search_obj->addIndex($options->getAppName());
$search_obj->setFormat("json");
$queryBuilder = new \QueryBuilder($search_obj);
$queryBuilder->channelType($_REQUEST["channeltype"]);
$queryBuilder->hits($vars["limitstart"], $vars["row"]);
$queryBuilder->orderBy($_REQUEST["orderby"]);
$queryBuilder->starttime($_REQUEST["starttime"]);
$queryBuilder->typeId($_REQUEST["typeid"]);
$queryBuilder->setSearch($searchtype, $kwtype, $keywors);
//execute search
$json = $search_obj->search();
//convert result
return json_decode($json, true);
}