本文整理汇总了PHP中Doctrine_Query::addOrderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::addOrderBy方法的具体用法?PHP Doctrine_Query::addOrderBy怎么用?PHP Doctrine_Query::addOrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Query
的用法示例。
在下文中一共展示了Doctrine_Query::addOrderBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQueryOrder
/**
* Build the order part from the query.
*
* The first arg is the field to be ordered and the $order
* arg is the correspondent order (ASC|DESC)
*
* If the $reset is set to true, all previous order should be removed
*
* @param string $field
* @param string $order
* @param bool $reset
* @return Bvb_Grid_Source_Doctrine
*/
public function buildQueryOrder($field, $order, $reset = false)
{
if ($reset) {
$this->_query->removeDqlQueryPart('orderby');
}
$this->_query->addOrderBy($field . ' ' . $order);
return $this;
}
示例2: tryToSortWithForeignColumn
protected function tryToSortWithForeignColumn(Doctrine_Query $query, array $sort)
{
$table = $this->getDmModule()->getTable();
if ('integer' === dmArray::get($table->getColumnDefinition($sort[0]), 'type')) {
if ($table->isI18nColumn($sort[0])) {
$query->addOrderBy(sprintf('%s.%s %s', $query->getJoinAliasForRelationAlias($table->getComponentName(), 'Translation'), $sort[0], $sort[1]));
// Success, skip default sorting by local column
return;
} elseif ($relation = $table->getRelationHolder()->getLocalByColumnName($sort[0])) {
if ($relation instanceof Doctrine_Relation_LocalKey && ($foreignTable = $relation->getTable()) instanceof dmDoctrineTable) {
if (($foreignColumn = $foreignTable->getIdentifierColumnName()) != 'id') {
if (!($joinAlias = $query->getJoinAliasForRelationAlias($table->getComponentName(), $relation->getAlias()))) {
$query->leftJoin(sprintf('%s.%s %s', $query->getRootAlias(), $relation->getAlias(), $relation->getAlias()));
$joinAlias = $relation->getAlias();
if ($foreignTable->isI18nColumn($foreignColumn)) {
$query->leftJoin(sprintf('%s.%s %s', $joinAlias, 'Translation', $joinAlias . 'Translation'));
}
}
if ($foreignTable->isI18nColumn($foreignColumn)) {
$query->addOrderBy(sprintf('%s.%s %s', $joinAlias . 'Translation', $foreignColumn, $sort[1]));
} else {
$query->addOrderBy(sprintf('%s.%s %s', $joinAlias, $foreignColumn, $sort[1]));
}
// Success, skip default sorting by local column
return;
}
}
}
} elseif ($table->isI18nColumn($sort[0])) {
$query->addOrderBy(sprintf('%s.%s %s', $query->getJoinAliasForRelationAlias($table->getComponentName(), 'Translation'), $sort[0], $sort[1]));
// Success, skip default sorting by local column
return;
}
if ($table->hasField($sort[0])) {
$query->addOrderBy($sort[0] . ' ' . $sort[1]);
}
}
示例3: hookOrderby
/**
* hookOrderBy
* builds DQL query orderby part from given parameter array
*
* @param array $params an array containing all fields which the built query
* should be ordered by
* @return boolean whether or not the hooking was successful
*/
public function hookOrderby($params)
{
if (!is_array($params)) {
return false;
}
foreach ($params as $name) {
$e = explode(' ', $name);
$order = 'ASC';
if (count($e) > 1) {
$order = $e[1] == 'DESC' ? 'DESC' : 'ASC';
}
$e = explode('.', $e[0]);
if (count($e) == 2) {
list($alias, $column) = $e;
$map = $this->query->getAliasDeclaration($alias);
$table = $map['table'];
if ($def = $table->getDefinitionOf($column)) {
$this->query->addOrderBy($alias . '.' . $column . ' ' . $order);
}
}
}
return true;
}
示例4: rec_query_add_sort
/**
* Add sort to Doctrine_Query.
*
* @param Doctrine_Query $q
* @param string $fld
* @param string $dir
*/
protected function rec_query_add_sort(Doctrine_Query $q, $fld, $dir)
{
$q->addOrderBy("{$fld} {$dir}");
}
示例5: addOrderByPositionOption
/**
* Adds orderby option to the query on the <field_name>
*
* @param Doctrine_Query $q
*/
private function addOrderByPositionOption(Doctrine_Query $q, $table_alias = 't', $filed_name = 'position')
{
$q->addOrderBy($table_alias . '.' . $filed_name);
}
示例6: addSortQuery
protected function addSortQuery(Doctrine_Query $query)
{
$sort = $this->getSort();
if ($sort) {
$query->addOrderBy(sprintf("%s %s", $sort[0], $sort[1]));
}
}
示例7: rec_query_add_sort
/**
* Handle custom sorters
*
* @param Doctrine_Query $q
* @param string $fld
* @param string $dir
*/
protected function rec_query_add_sort(Doctrine_Query $q, $fld, $dir)
{
if ($fld == 'cre_username') {
$q->addOrderBy("cu.user_username {$dir}");
} elseif ($fld == 'upd_username') {
$q->addOrderBy("uu.user_username {$dir}");
} else {
parent::rec_query_add_sort($q, $fld, $dir);
}
}
示例8: addSortQuery
/**
* Add sort query
*
* @param Doctrine_Query $q
* @return void
*/
protected function addSortQuery($q)
{
$q->addOrderBy('root_id, lft');
}