当前位置: 首页>>代码示例>>PHP>>正文


PHP SqlWalker::walkOrderByClause方法代码示例

本文整理汇总了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;
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:42,代码来源:SortableNullsWalker.php

示例2: walkOrderByClause

 /**
  * {@inheritDoc}
  */
 public function walkOrderByClause($orderByClause)
 {
     $result = parent::walkOrderByClause($orderByClause);
     return $this->replace($this->replacements, $result);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:8,代码来源:TranslationWalker.php

示例3: getSql

 /**
  * @override
  */
 public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
 {
     return 'ROW_NUMBER() OVER(' . trim($sqlWalker->walkOrderByClause($this->orderByClause)) . ')';
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:7,代码来源:RowNumberOverFunction.php

示例4: walkOrderByClause

 /**
  * {@inheritDoc}
  */
 public function walkOrderByClause($orderByClause)
 {
     $result = parent::walkOrderByClause($orderByClause);
     return str_replace(array_keys($this->replacements), array_values($this->replacements), $result);
 }
开发者ID:rdohms,项目名称:DoctrineExtensions,代码行数:8,代码来源:TranslationWalker.php


注:本文中的Doctrine\ORM\Query\SqlWalker::walkOrderByClause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。