當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。