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


PHP QueryBuilder::andHaving方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Query\QueryBuilder::andHaving方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::andHaving方法的具体用法?PHP QueryBuilder::andHaving怎么用?PHP QueryBuilder::andHaving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Query\QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::andHaving方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: andHavingDelegatesToConcreteQueryBuilder

 /**
  * @test
  */
 public function andHavingDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->andHaving('uid=1', 'type=9')->shouldBeCalled()->willReturn($this->subject);
     $this->subject->andHaving('uid=1', 'type=9');
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:8,代码来源:QueryBuilderTest.php

示例3: andHaving

 /**
  * Adds a restriction over the groups of the query, forming a logical
  * conjunction with any existing having restrictions.
  *
  * @param mixed $having The restriction to append.
  *
  * @return self
  */
 public function andHaving($having)
 {
     $this->qb->andHaving($having);
     return $this;
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:SqlQueryBuilder.php

示例4: applySearchQueryRelationship

 /**
  * @param QueryBuilder $q
  * @param array        $tables          $tables[0] should be primary table
  * @param bool         $innerJoinTables
  * @param null         $whereExpression
  * @param null         $having
  */
 protected function applySearchQueryRelationship(QueryBuilder $q, array $tables, $innerJoinTables, $whereExpression = null, $having = null)
 {
     $primaryTable = $tables[0];
     unset($tables[0]);
     $joinType = $innerJoinTables ? 'join' : 'leftJoin';
     $this->useDistinctCount = true;
     $joins = $q->getQueryPart('join');
     if (!array_key_exists($primaryTable['alias'], $joins)) {
         $q->{$joinType}($primaryTable['from_alias'], MAUTIC_TABLE_PREFIX . $primaryTable['table'], $primaryTable['alias'], $primaryTable['condition']);
         foreach ($tables as $table) {
             $q->{$joinType}($table['from_alias'], MAUTIC_TABLE_PREFIX . $table['table'], $table['alias'], $table['condition']);
         }
         if ($whereExpression) {
             $q->andWhere($whereExpression);
         }
         if ($having) {
             $q->andHaving($having);
         }
         $q->groupBy('l.id');
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:28,代码来源:LeadRepository.php


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