本文整理匯總了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);
}