本文整理汇总了PHP中Doctrine\ORM\Query\SqlWalker::walkOrderByClause方法的典型用法代码示例。如果您正苦于以下问题:PHP SqlWalker::walkOrderByClause方法的具体用法?PHP SqlWalker::walkOrderByClause怎么用?PHP SqlWalker::walkOrderByClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query\SqlWalker
的用法示例。
在下文中一共展示了SqlWalker::walkOrderByClause方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: walkOrderByClause
public function walkOrderByClause($orderByClause)
{
$sql = parent::walkOrderByClause($orderByClause);
if ($nullFields = $this->getQuery()->getHint('SortableNullsWalker.fields')) {
if (is_array($nullFields)) {
$platform = $this->getConnection()->getDatabasePlatform()->getName();
switch ($platform) {
case 'mysql':
// for mysql the nulls last is represented with - before the field name
foreach ($nullFields as $field => $sorting) {
/**
* NULLs are considered lower than any non-NULL value,
* except if a – (minus) character is added before
* the column name and ASC is changed to DESC, or DESC to ASC;
* this minus-before-column-name feature seems undocumented.
*/
if ('NULLS LAST' === $sorting) {
$sql = preg_replace_callback('/ORDER BY (.+)' . '(' . $field . ') (ASC|DESC)/i', function ($matches) {
if ($matches[3] === 'ASC') {
$order = 'DESC';
} elseif ($matches[3] === 'DESC') {
$order = 'ASC';
}
return 'ORDER BY -' . $matches[1] . $matches[2] . ' ' . $order;
}, $sql);
}
}
break;
case 'oracle':
case 'postgresql':
foreach ($nullFields as $field => $sorting) {
$sql = preg_replace('/(\\.' . $field . ') (ASC|DESC)?\\s*/i', "\$1 \$2 " . $sorting, $sql);
}
break;
default:
// I don't know for other supported platforms.
break;
}
}
}
return $sql;
}
示例2: walkOrderByClause
/**
* {@inheritDoc}
*/
public function walkOrderByClause($orderByClause)
{
$result = parent::walkOrderByClause($orderByClause);
return $this->replace($this->replacements, $result);
}
示例3: getSql
/**
* @override
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'ROW_NUMBER() OVER(' . trim($sqlWalker->walkOrderByClause($this->orderByClause)) . ')';
}
示例4: walkOrderByClause
/**
* {@inheritDoc}
*/
public function walkOrderByClause($orderByClause)
{
$result = parent::walkOrderByClause($orderByClause);
return str_replace(array_keys($this->replacements), array_values($this->replacements), $result);
}