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


PHP QueryBuilder::addFilter方法代码示例

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


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

示例1: filterListQuery

 /**
  * Filters the displayed fields by the passed filter value.
  *
  * @param \Doctrine\ORM\QueryBuilder $builder
  * @param array|null $filters
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function filterListQuery(\Doctrine\ORM\QueryBuilder $builder, $filters = null)
 {
     $expr = Shopware()->Models()->getExpressionBuilder();
     if (!empty($filters)) {
         foreach ($filters as $filter) {
             if (empty($filter['property']) || $filter['value'] === null || $filter['value'] === '') {
                 continue;
             }
             switch ($filter['property']) {
                 case "free":
                     $builder->andWhere($expr->orX($expr->like('orders.number', '?1'), $expr->like('orders.invoiceAmount', '?1'), $expr->like('orders.transactionId', '?1'), $expr->like('billing.company', '?3'), $expr->like('customer.email', '?3'), $expr->like('billing.lastName', '?3'), $expr->like('billing.firstName', '?3'), $expr->like('orders.comment', '?3'), $expr->like('orders.customerComment', '?3'), $expr->like('orders.internalComment', '?3')));
                     $builder->setParameter(1, $filter['value'] . '%');
                     $builder->setParameter(3, '%' . $filter['value'] . '%');
                     break;
                 case "from":
                     $tmp = new \DateTime($filter['value']);
                     $builder->andWhere('orders.orderTime > :orderTimeFrom');
                     $builder->setParameter('orderTimeFrom', $tmp->format('Ymd'));
                     break;
                 case "to":
                     $tmp = new \Zend_Date($filter['value']);
                     $tmp->setHour('23');
                     $tmp->setMinute('59');
                     $tmp->setSecond('59');
                     $builder->andWhere('orders.orderTime <= :orderTimeTo');
                     $builder->setParameter('orderTimeTo', $tmp->get('yyyy-MM-dd HH:mm:ss'));
                     break;
                 case 'details.articleNumber':
                     $builder->leftJoin('orders.details', 'details');
                     $builder->andWhere('details.articleNumber LIKE :articleNumber');
                     $builder->setParameter('articleNumber', $filter['value']);
                     break;
                 default:
                     $builder->addFilter(array($filter));
             }
         }
     }
     return $builder;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:46,代码来源:Repository.php

示例2: addFilter

 /**
  * Adds filters to the query results.
  *
  * <code>
  *      $this->addFilter($builder, array(array(
  *          'property' => 'name'
  *          'value' => 'A%'
  *      )));
  * </code>
  *
  * @param QueryBuilder $builder
  * @param array $filter
  * @return QueryBuilder
  */
 public function addFilter(QueryBuilder $builder, array $filter)
 {
     return $builder->addFilter($filter);
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:18,代码来源:ModelRepository.php


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