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


PHP QueryBuilder::where方法代码示例

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


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

示例1: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     $paramcount = 0;
     if (isset($this->gID) && $this->gID > 0) {
         $query->where('gID = ?')->setParameter($paramcount++, $this->gID);
     }
     switch ($this->sortBy) {
         case "alpha":
             $query->orderBy('pName', 'ASC');
             break;
         case "date":
             $query->orderBy('pDateAdded', 'DESC');
             break;
     }
     switch ($this->featured) {
         case "featured":
             $query->andWhere("pFeatured = 1");
             break;
         case "nonfeatured":
             $query->andWhere("pFeatured = 0");
             break;
     }
     if ($this->activeOnly) {
         $query->andWhere("pActive = 1");
     }
     if ($this->search) {
         $query->andWhere('pName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
     }
     return $query;
 }
开发者ID:Rgeelen,项目名称:vivid_store,代码行数:30,代码来源:ProductList.php

示例2: where

 public function where($where)
 {
     if (!$this->isWhereInConditions($where)) {
         return $this;
     }
     return parent::where($where);
 }
开发者ID:codeages,项目名称:biz-framework,代码行数:7,代码来源:DynamicQueryBuilder.php

示例3: where

 public function where($column, $operator = null, $value = null, $boolean = 'and')
 {
     $args = func_get_args();
     if (count($args) == 1) {
         parent::where($args[0]);
         return $this;
     }
     $column = $args[0];
     $boolean = 'and';
     $operator = '=';
     if (count($args) == 2) {
         $value = $args[1];
     }
     if (count($args) == 3) {
         $operator = $args[1];
         $value = $args[2];
     }
     if (count($args) == 4) {
         $operator = $args[1];
         $value = $args[2];
         $boolean = $args[3];
     }
     if (is_array($value)) {
         $operator = $operator == '=' ? 'in' : 'notIn';
         $where_clause = $this->expr()->{$operator}($column, parent::createNamedParameter($value, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY));
     } else {
         $where_clause = $column . $operator . parent::createNamedParameter($value);
     }
     if ($boolean == 'and') {
         parent::andWhere($where_clause);
     } elseif ($boolean == 'or') {
         parent::orWhere($where_clause);
     }
     return $this;
 }
开发者ID:arduanov,项目名称:pimple-active-record,代码行数:35,代码来源:QueryBuilder.php

示例4: where

 /**
  * @param string  $predicates The restriction predicates.
  *
  * @return QueryBuilder
  */
 public function where($predicates)
 {
     if ($this->mergeNextWhere) {
         $this->mergeNextWhere = false;
         parent::andWhere($predicates);
     } else {
         parent::where($predicates);
     }
     return $this;
 }
开发者ID:avalonphp,项目名称:database,代码行数:15,代码来源:QueryBuilder.php

示例5: beforeGetList

 /**
  * @param QueryBuilder $queryBuilder
  * @param Request $request
  * @return QueryBuilder
  */
 public function beforeGetList(QueryBuilder $queryBuilder, Request $request)
 {
     $from = $request->query->get('from');
     $to = $request->query->get('to');
     $author = $request->query->get('author');
     if (!$from && !$to && !$author) {
         return $queryBuilder;
     } else {
         return $queryBuilder->where($queryBuilder->expr()->like('author', '?'))->andWhere('o.created BETWEEN ? AND ?')->setParameter(0, $author ? $author : self::DEFAULT_AUTHOR)->setParameter(1, $from ? $from : self::DEFAULT_FROM)->setParameter(2, $to ? $to : self::DEFAULT_TO);
     }
 }
开发者ID:scottie34,项目名称:silex-fwk,代码行数:16,代码来源:PostDecorator.php

示例6: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     $paramcount = 0;
     if (isset($this->gID) && $this->gID > 0) {
         $query->where('gID = ?')->setParameter($paramcount++, $this->gID);
     }
     switch ($this->sortBy) {
         case "alpha":
             $query->orderBy('drName', 'ASC');
             break;
     }
     if ($this->search) {
         $query->andWhere('drName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
     }
     $query->andWhere('drDeleted is NULL');
     return $query;
 }
开发者ID:Janoinen,项目名称:vivid_store,代码行数:17,代码来源:DiscountRuleList.php

示例7: buildWhere

 /**
  * Builds the WHERE clause from $filter
  * @param QueryBuilder $qb
  * @param array $filters should be an array with arrays wich contains 3 datas
  * [
  *    ['column_name', 'expr_type', 'value'],
  *    [],
  *    ...
  * ]
  * expr_types: 'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'like', 'in', 'notIn', 'notLike'
  * @return self
  */
 protected function buildWhere(QueryBuilder $qb, array $filters = [])
 {
     if (!empty($filters)) {
         $expr = $qb->expr()->andX();
         foreach ($filters as $f) {
             $column = $f[0];
             $expr_type = $f[1];
             $value = isset($f[2]) ? $f[2] : null;
             $type = \PDO::PARAM_STR;
             if ($this->getColumn($column) === null) {
                 throw Schema\SchemaException::columnDoesNotExist($column, $this->table_name);
             }
             if (!in_array($expr_type, $this->getExpressionTypes())) {
                 throw QueryBuilderException::expressionTypeDoesNotExist($expr_type);
             }
             if (in_array($expr_type, ['in', 'notIn']) && is_array($value)) {
                 switch ($this->column_types[$column]) {
                     case 'integer':
                         $type = \Doctrine\DBAL\Connection::PARAM_INT_ARRAY;
                         break;
                     case 'string':
                         $type = \Doctrine\DBAL\Connection::PARAM_STR_ARRAY;
                         break;
                 }
             }
             $expr->add($qb->expr()->{$expr_type}($this->conn->quoteIdentifier($column), $qb->createNamedParameter($value, $type)));
         }
         $qb->where($expr);
     }
     return $this;
 }
开发者ID:schwaen,项目名称:doctrine-dbal-extensions,代码行数:43,代码来源:Model.php

示例8: timedWhere

 /**
  * Set the QueryBuilder where parameters.
  *
  * @param QueryBuilder $query
  * @param string       $type
  */
 private function timedWhere(QueryBuilder $query, $type)
 {
     if ($type === 'publish') {
         $query->where('status = :oldstatus')->andWhere('datepublish < CURRENT_TIMESTAMP')->setParameter('oldstatus', 'timed')->setParameter('newstatus', 'published');
     } else {
         $query->where('status = :oldstatus')->andWhere('datedepublish <= CURRENT_TIMESTAMP')->andWhere('datedepublish > :zeroday')->andWhere('datechanged < datedepublish')->setParameter('oldstatus', 'published')->setParameter('newstatus', 'held')->setParameter('zeroday', '1900-01-01 00:00:01');
     }
 }
开发者ID:realitygaps,项目名称:site-v20,代码行数:14,代码来源:Storage.php

示例9: addWhere

 /**
  * @inheritdoc
  */
 protected function addWhere(QueryBuilder $queryBuilder)
 {
     $queryBuilder->where('`main`.`status` != :status');
 }
开发者ID:acp3,项目名称:module-newsletter,代码行数:7,代码来源:AccountDataGridRepository.php

示例10: timedWhere

 /**
  * Set the QueryBuilder where parameters.
  *
  * @param QueryBuilder $query
  * @param string       $type
  */
 private function timedWhere(QueryBuilder $query, $type)
 {
     if ($type === 'publish') {
         $query->where('status = :oldstatus')->andWhere('datepublish < :currenttime')->setParameter('oldstatus', 'timed')->setParameter('newstatus', 'published')->setParameter('currenttime', new \DateTime(), \Doctrine\DBAL\Types\Type::DATETIME);
     } else {
         $query->where('status = :oldstatus')->andWhere('datedepublish <= :currenttime')->andWhere('datedepublish > :zeroday')->andWhere('datechanged < datedepublish')->setParameter('oldstatus', 'published')->setParameter('newstatus', 'held')->setParameter('zeroday', '1900-01-01 00:00:01')->setParameter('currenttime', new \DateTime(), \Doctrine\DBAL\Types\Type::DATETIME);
     }
 }
开发者ID:Cinal,项目名称:bolt,代码行数:14,代码来源:Storage.php

示例11: where

 /**
  * @param array $conditions
  * @return $this
  */
 public function where($conditions)
 {
     $this->queryBuilder->where($this->clause($conditions));
     return $this;
 }
开发者ID:marcojetson,项目名称:freckle,代码行数:9,代码来源:Query.php

示例12: whereDelegatesToConcreteQueryBuilder

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

示例13: where

 /**
  * Specifies one or more restrictions to the query result.
  * Replaces any previously specified restrictions, if any.
  *
  * @param mixed $predicates The restriction predicates.
  *
  * @return self
  */
 public function where($predicates)
 {
     $this->qb->where($predicates);
     return $this;
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:SqlQueryBuilder.php

示例14: modifyCountDateDiffQuery

 /**
  * Modify the query to count how many rows is between a range of date diff in seconds
  *
  * @param  QueryBuilder $query
  * @param  string       $dateColumn1
  * @param  string       $dateColumn2
  * @param  integer      $startSecond
  * @param  integer      $endSecond
  * @param  array        $filters will be added to where claues
  * @param  string       $tablePrefix
  */
 public function modifyCountDateDiffQuery(QueryBuilder &$query, $dateColumn1, $dateColumn2, $startSecond = 0, $endSecond = 60, $tablePrefix = 't')
 {
     $query->select('COUNT(' . $tablePrefix . '.' . $dateColumn1 . ') AS count');
     $query->where('TIMESTAMPDIFF(SECOND, ' . $tablePrefix . '.' . $dateColumn1 . ', ' . $tablePrefix . '.' . $dateColumn2 . ') >= :startSecond');
     $query->andWhere('TIMESTAMPDIFF(SECOND, ' . $tablePrefix . '.' . $dateColumn1 . ', ' . $tablePrefix . '.' . $dateColumn2 . ') < :endSecond');
     $query->setParameter('startSecond', $startSecond);
     $query->setParameter('endSecond', $endSecond);
 }
开发者ID:Yame-,项目名称:mautic,代码行数:19,代码来源:ChartQuery.php

示例15: verify

 /**
  * @param int[]         $expected
  * @param string        $permission
  * @param UserInterface $user
  * @param string[]      $orX
  * @param string        $where
  */
 private function verify(array $expected, $permission, UserInterface $user = null, array $orX = [], $where = null)
 {
     $fails = [];
     $permission = strtoupper($permission);
     $DBALQueryBuilder = new DBALQueryBuilder($this->connection);
     $DBALQueryBuilder->select('*')->from('posts', 'p');
     if (null !== $where) {
         $DBALQueryBuilder->where($where);
     }
     $this->aclFilter->apply($DBALQueryBuilder, $permission, 'Nuxia\\AclBundle\\Tests\\Model\\PostObject', 'p.id', $user, $orX);
     try {
         $this->assertEquals($expected, $this->getPostIds($DBALQueryBuilder), 'DBALQueryBuilder failed');
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         $fails[] = $e;
     }
     $ORMQueryBuilder = $this->em->createQueryBuilder();
     $ORMQueryBuilder->select('p')->from('Nuxia\\AclBundle\\Tests\\Model\\PostObject', 'p');
     if (null !== $where) {
         $ORMQueryBuilder->where($where);
     }
     $cloneORMQueryBuilder = clone $ORMQueryBuilder;
     $query = $this->aclFilter->apply($ORMQueryBuilder, $permission, 'Nuxia\\AclBundle\\Tests\\Model\\PostObject', 'p.id', $user, $orX);
     try {
         $this->assertEquals($expected, $this->getPostIds($query), 'ORMQueryBuilder failed');
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         $fails[] = $e;
     }
     $query = $this->aclFilter->apply($cloneORMQueryBuilder->getQuery(), $permission, 'Nuxia\\AclBundle\\Tests\\Model\\PostObject', 'p.id', $user, $orX);
     try {
         $this->assertEquals($expected, $this->getPostIds($query), 'ORMQuery failed');
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         $fails[] = $e;
     }
     if (!empty($fails)) {
         $messages = [];
         /** @var \PHPUnit_Framework_ExpectationFailedException $e */
         foreach ($fails as $e) {
             $messages[] = $e->getMessage() . $e->getComparisonFailure()->getDiff();
         }
         $this->fail(implode(PHP_EOL, $messages));
     }
 }
开发者ID:dragosprotung,项目名称:AclBundle,代码行数:49,代码来源:AclFilterTest.php


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