當前位置: 首頁>>代碼示例>>PHP>>正文


PHP QueryBuilder::orHaving方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Query\QueryBuilder::orHaving方法的典型用法代碼示例。如果您正苦於以下問題:PHP QueryBuilder::orHaving方法的具體用法?PHP QueryBuilder::orHaving怎麽用?PHP QueryBuilder::orHaving使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Query\QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::orHaving方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: make

 /**
  * @param array $request
  * @return array
  */
 public function make(array $request)
 {
     $output = ['data' => [], 'draw' => $request['draw'], 'recordsFiltered' => 0, 'recordsTotal' => 0];
     /**
      * Order By
      */
     if (isset($request['order'])) {
         for ($i = 0; $i < count($request['order']); ++$i) {
             $j = intval($request['order'][$i]['column']);
             if ($request['columns'][$j]['orderable'] != 'true') {
                 continue;
             }
             $column = $request['columns'][$j]['data'];
             $sort = $request['order'][$i]['dir'];
             $this->query->addOrderBy($column, $sort);
         }
     }
     /**
      * Count All
      */
     $temp = clone $this->query;
     $temp->resetQueryPart('select');
     $temp->resetQueryPart('orderBy');
     $temp->select("COUNT(*)");
     $output['recordsTotal'] = $temp->execute()->fetchColumn(0);
     /**
      * Filter
      */
     for ($i = 0; $i < count($request['columns']); ++$i) {
         if ($request['columns'][$i]['searchable'] != 'true') {
             continue;
         }
         $value = $request['columns'][$i]['search']['value'];
         if (strlen($value) > 0) {
             $column = $request['columns'][$i]['data'];
             $value = $this->query->getConnection()->quote("{$value}%");
             $this->query->andHaving($this->query->expr()->like($column, $value));
         }
     }
     /**
      * Search
      */
     if (isset($request['search'])) {
         $value = $request['search']['value'];
         if (strlen($value) > 0) {
             for ($i = 0; $i < count($request['columns']); ++$i) {
                 if ($request['columns'][$i]['searchable'] != 'true') {
                     continue;
                 }
                 $column = $request['columns'][$i]['data'];
                 $this->query->orHaving($this->query->expr()->like($column, ':search'));
             }
             $this->query->setParameter('search', "%{$value}%");
         }
     }
     /**
      * Count Filtered
      */
     $temp = clone $this->query;
     $temp->resetQueryPart('orderBy');
     $output['recordsFiltered'] = $temp->execute()->rowCount();
     /**
      * Limit
      */
     if (isset($request['start'])) {
         $this->query->setFirstResult($request['start']);
     }
     if (isset($request['length'])) {
         $this->query->setMaxResults($request['length']);
     }
     /**
      * Fetch Results
      */
     $output['data'] = $this->query->execute()->fetchAll(\PDO::FETCH_ASSOC);
     /**
      * Add Filter
      */
     return $output;
 }
開發者ID:vaibhavpandeyvpz,項目名稱:acraviz,代碼行數:83,代碼來源:Datatables.php

示例2: orHavingDelegatesToConcreteQueryBuilder

 /**
  * @test
  */
 public function orHavingDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->orHaving('uid=1', 'type=9')->shouldBeCalled()->willReturn($this->subject);
     $this->subject->orHaving('uid=1', 'type=9');
 }
開發者ID:dachcom-digital,項目名稱:TYPO3.CMS,代碼行數:8,代碼來源:QueryBuilderTest.php

示例3: orHaving

 /**
  * Adds a restriction over the groups of the query, forming a logical
  * disjunction with any existing having restrictions.
  *
  * @param mixed $having The restriction to add.
  *
  * @return self
  */
 public function orHaving($having)
 {
     $this->qb->orHaving($having);
     return $this;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:13,代碼來源:SqlQueryBuilder.php


注:本文中的Doctrine\DBAL\Query\QueryBuilder::orHaving方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。