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


PHP QueryBuilder::getParameters方法代码示例

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


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

示例1: testCreateDataSet_conflictingFilters

 public function testCreateDataSet_conflictingFilters()
 {
     $request = $this->getBaseRequest();
     $this->qb->andWhere('p.id = ?0')->setParameter(0, 'Test');
     $request->columnFilters[0] = 'test';
     $dataSet = $this->dataSource->createDataSet($request);
     $where = $this->qb->getDQLPart('where')->getParts();
     $this->assertCount(2, $where);
     $this->assertCount(2, $this->qb->getParameters());
 }
开发者ID:deft,项目名称:datatables-php,代码行数:10,代码来源:QueryBuilderDataSourceTest.php

示例2: getSize

 /**
  * {@inheritdoc}
  */
 public function getSize()
 {
     if (null === $this->size) {
         $qb = clone $this->queryBuilder;
         $alias = current($qb->getRootAliases());
         $qb->setParameters($this->queryBuilder->getParameters());
         $qb->select("count({$alias})");
         $this->size = (int) $qb->getQuery()->getSingleScalarResult();
     }
     return $this->size;
 }
开发者ID:mcdir,项目名称:SonatraFormExtensionsBundle,代码行数:14,代码来源:AjaxORMQueryBuilderLoader.php

示例3: cloneQuery

 /**
  * Clones a query.
  *
  * @param QueryBuilder $query The query.
  *
  * @return QueryBuilder The cloned query.
  */
 public static function cloneQuery($query)
 {
     /* @var $cloneQuery QueryBuilder */
     $cloneQuery = clone $query;
     $cloneQuery->setParameters(clone $query->getParameters());
     return $cloneQuery;
 }
开发者ID:nnmer,项目名称:utils-bundle,代码行数:14,代码来源:Pagination.php

示例4:

 function it_uses_comparison_specific_dql_alias_if_passed(QueryBuilder $qb, ArrayCollection $parameters)
 {
     $this->beConstructedWith(Comparison::GT, 'age', 18, null);
     $qb->getParameters()->willReturn($parameters);
     $parameters->count()->willReturn(10);
     $qb->setParameter('comparison_10', 18)->shouldBeCalled();
     $this->getFilter($qb, 'x')->shouldReturn('x.age > :comparison_10');
 }
开发者ID:happyr,项目名称:doctrine-specification,代码行数:8,代码来源:ComparisonSpec.php

示例5: it_ends_with_wildcard_when_using_starts_with

 public function it_ends_with_wildcard_when_using_starts_with(QueryBuilder $qb, ArrayCollection $parameters)
 {
     $this->beConstructedWith($this->field, $this->value, Like::STARTS_WITH, "dqlAlias");
     $qb->getParameters()->willReturn($parameters);
     $parameters->count()->willReturn(1);
     $qb->setParameter("comparison_1", "bar%")->shouldBeCalled();
     $this->match($qb, null);
 }
开发者ID:happyr,项目名称:doctrine-specification,代码行数:8,代码来源:LikeSpec.php

示例6:

 function it_returns_expression_func_object(QueryBuilder $qb, ArrayCollection $parameters, Expr $expr)
 {
     $dqlAlias = 'a';
     $qb->expr()->willReturn($expr);
     $expr->in(sprintf('%s.%s', $dqlAlias, $this->field), ':in_10')->shouldBeCalled();
     $qb->getParameters()->willReturn($parameters);
     $parameters->count()->willReturn(10);
     $qb->setParameter('in_10', $this->value)->shouldBeCalled();
     $this->getFilter($qb, null);
 }
开发者ID:happyr,项目名称:doctrine-specification,代码行数:10,代码来源:InSpec.php

示例7: removeExtraParameters

 /**
  * We update the query to count, get ids and fetch data, so, we can lost expected query builder parameters,
  * and we have to remove them
  *
  * @param QueryBuilder $qb
  */
 public static function removeExtraParameters(QueryBuilder $qb)
 {
     $parameters = $qb->getParameters();
     $dql = $qb->getDQL();
     foreach ($parameters as $parameter) {
         if (strpos($dql, ':' . $parameter->getName()) === false) {
             $parameters->removeElement($parameter);
         }
     }
     $qb->setParameters($parameters);
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:17,代码来源:QueryBuilderUtility.php

示例8: andWherePupilNotIn

 /**
  * @param QueryBuilder $query
  * @param QueryBuilder $subQuery
  * @return QueryBuilder $query with query's and subQuery's parameters.
  */
 private function andWherePupilNotIn(QueryBuilder $query, QueryBuilder $subQuery, $EleveQueryAlias)
 {
     $query->andWhere($query->expr()->notIn($EleveQueryAlias . ".id", $subQuery->getDQL()));
     /**
      * @var Parameter $param
      */
     foreach ($subQuery->getParameters() as $param) {
         $query->setParameter($param->getName(), $param->getValue(), $param->getType());
     }
     return $query;
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:16,代码来源:ActivityRepositoryAbstract.php

示例9: fixUnusedParameters

 /**
  * Removes unused parameters from query builder
  *
  * @param QueryBuilder $qb
  */
 public function fixUnusedParameters(QueryBuilder $qb)
 {
     $dql = $qb->getDQL();
     $usedParameters = [];
     /** @var $parameter \Doctrine\ORM\Query\Parameter */
     foreach ($qb->getParameters() as $parameter) {
         if ($this->dqlContainsParameter($dql, $parameter->getName())) {
             $usedParameters[$parameter->getName()] = $parameter->getValue();
         }
     }
     $qb->setParameters($usedParameters);
 }
开发者ID:northdakota,项目名称:platform,代码行数:17,代码来源:QueryBuilderTools.php

示例10: getPaginator

 /**
  * Get Paginator
  * 
  * @param integer $limit ( limit per page )
  * @param array $options
  * @return \Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination
  */
 protected function getPaginator($limit = 30, $options = array())
 {
     $page = $this->get('request')->query->get('page', 1);
     $cnt = 0;
     if ($this->get('request')->query->has('page')) {
         $page = $this->get('request')->query->get('page');
         $this->get('session')->set('_pager_' . $this->get('request')->get('_route'), $page);
     } elseif ($this->get('session')->has('_pager_' . $this->get('request')->get('_route'))) {
         $page = $this->get('session')->get('_pager_' . $this->get('request')->get('_route'));
     }
     if (isset($options['total_item_count']) and (int) $options['total_item_count']) {
         $cnt = $options['total_item_count'];
     }
     $this->paginator = $this->get('knp_paginator');
     if (is_array($this->query) or $this->query instanceof QueryBuilder) {
         $pagination = $this->paginator->paginate($this->query, $page, $limit, $options);
     } elseif ($this->query instanceof NativeQuery) {
         $rsm = new ResultSetMapping();
         $rsm->addScalarResult('cnt', 'cnt');
         $q = strstr($this->query->getSQL(), " FROM ");
         $q = "SELECT COUNT(*) cnt " . $q;
         $cntQuery = $this->em->createNativeQuery($q, $rsm)->setParameters($this->query->getParameters());
         try {
             $cnt = $cntQuery->getSingleScalarResult();
         } catch (\Doctrine\Orm\NoResultException $e) {
             $cnt = 0;
         }
         $sql = $this->query->getSQL();
         $pagination = $this->paginator->paginate(array());
         $sort_name = $pagination->getPaginatorOption('sortFieldParameterName');
         $sort_direction_name = $pagination->getPaginatorOption('sortDirectionParameterName');
         if ($this->get('request')->query->has($sort_name) and $this->get('request')->query->has($sort_direction_name)) {
             $sql .= ' ORDER BY ' . $this->get('request')->query->get($sort_name) . ' ' . $this->get('request')->query->get($sort_direction_name);
         } elseif (isset($options['default_sort']) and $options['default_sort']) {
             $sql .= ' ORDER BY ';
             foreach ($options['default_sort'] as $field => $type) {
                 $sql .= $field . ' ' . $type . ',';
             }
             $sql = trim($sql, ',');
         }
         if (!isset($options['not_use_limit_offset'])) {
             $offset = $limit * ($page - 1);
             $this->query->setSQL($sql . ' LIMIT ' . $limit . ' OFFSET ' . $offset);
         }
         $pagination->setCurrentPageNumber($page);
         $pagination->setItemNumberPerPage($limit);
         $pagination->setTotalItemCount($cnt);
         $pagination->setItems($this->query->getResult());
     }
     $pagination->setTemplate($this->container->getParameter('zk2_admin_panel.pagination_template'));
     $pagination->setSortableTemplate($this->container->getParameter('zk2_admin_panel.sortable_template'));
     return compact('pagination');
 }
开发者ID:zk2,项目名称:admin-panel-bundle,代码行数:60,代码来源:AdminPanelController.php

示例11: getRawSQLFromORMQueryBuilder

 /**
  * @param QueryBuilder $qb
  *
  * @return string
  */
 public function getRawSQLFromORMQueryBuilder(QueryBuilder $qb)
 {
     $sql = $qb->getDQL();
     $parameters = $qb->getParameters();
     /** @var Query\Parameter $param */
     foreach ($parameters as $param) {
         if (is_array($param->getValue()) && !empty($param->getValue())) {
             $sql = str_replace(':' . $param->getName(), "'" . implode("', '", $param->getValue()) . "'", $sql);
         } else {
             $sql = str_replace(':' . $param->getName(), "'" . $param->getValue() . "'", $sql);
         }
     }
     return $sql;
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:19,代码来源:AbstractRepositoryTestCase.php

示例12: getItemsCountInCategory

 /**
  * {@inherit}
  */
 public function getItemsCountInCategory(CategoryInterface $category, QueryBuilder $categoryQb = null)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select($qb->expr()->count('distinct i'));
     $qb->from($this->entityName, 'i');
     $qb->join('i.categories', 'node');
     if (null === $categoryQb) {
         $qb->where('node.id = :nodeId');
         $qb->setParameter('nodeId', $category->getId());
     } else {
         $qb->where($categoryQb->getDqlPart('where'));
         $qb->setParameters($categoryQb->getParameters());
     }
     return $qb->getQuery()->getSingleScalarResult();
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:18,代码来源:AbstractItemCategoryRepository.php

示例13: applyMassActionParameters

 /**
  * Applies mass action parameters on the query builder
  *
  * @param QueryBuilder $qb
  * @param bool         $inset
  * @param array        $values
  */
 public function applyMassActionParameters($qb, $inset, $values)
 {
     if (!empty($values)) {
         $valueWhereCondition = $inset ? $qb->expr()->in($this->getAlias(), $values) : $qb->expr()->notIn($this->getAlias(), $values);
         $qb->andWhere($valueWhereCondition);
     }
     if (null !== $qb->getDQLPart('where')) {
         $whereParts = $qb->getDQLPart('where')->getParts();
         $qb->resetDQLPart('where');
         foreach ($whereParts as $part) {
             if (!is_string($part) || !strpos($part, 'entityIds')) {
                 $qb->andWhere($part);
             }
         }
     }
     $qb->setParameters($qb->getParameters()->filter(function ($parameter) {
         return $parameter->getName() !== 'entityIds';
     }));
     // remove limit of the query
     $qb->setMaxResults(null);
 }
开发者ID:ronanguilloux,项目名称:CustomEntityBundle,代码行数:28,代码来源:CustomEntityRepository.php

示例14: testApply

 /**
  * @dataProvider applyDataProvider
  */
 public function testApply($platform, $value, $comparisonType, $expectedDql, $expectedParams)
 {
     $paramCounter = 0;
     $em = $this->getMock('Doctrine\\ORM\\EntityManagerInterface');
     $qb = new QueryBuilder($em);
     $ds = $this->getMock('Oro\\Bundle\\FilterBundle\\Datasource\\Orm\\OrmFilterDatasourceAdapter', ['generateParameterName', 'getDatabasePlatform'], [$qb]);
     $ds->expects($this->any())->method('generateParameterName')->willReturnCallback(function () use(&$paramCounter) {
         return sprintf('param%s', ++$paramCounter);
     });
     $ds->expects($this->any())->method('getDatabasePlatform')->willReturn($platform);
     $data = ['type' => $comparisonType, 'value' => $value];
     $em->expects($this->any())->method('getExpressionBuilder')->willReturn(new Query\Expr());
     $qb->select('j')->from('TestEntity', 'j');
     $this->filter->apply($ds, $data);
     $this->assertEquals($expectedDql, $qb->getDQL());
     $params = [];
     /** @var Query\Parameter $param */
     foreach ($qb->getParameters() as $param) {
         $params[$param->getName()] = $param->getValue();
     }
     $this->assertEquals($expectedParams, $params);
 }
开发者ID:Maksold,项目名称:platform,代码行数:25,代码来源:CommandWithArgsFilterTest.php

示例15: addCriteria

 /**
  * @param QueryBuilder $qb
  * @param Criteria     $criteria
  */
 public static function addCriteria(QueryBuilder $qb, Criteria $criteria)
 {
     $rootAlias = $qb->getRootAlias();
     $visitor = new QueryExpressionVisitor($rootAlias);
     if ($whereExpression = $criteria->getWhereExpression()) {
         $qb->andWhere($visitor->dispatch($whereExpression));
         foreach ($visitor->getParameters() as $parameter) {
             $qb->getParameters()->add($parameter);
         }
     }
     if ($criteria->getOrderings()) {
         foreach ($criteria->getOrderings() as $sort => $order) {
             $qb->addOrderBy($rootAlias . '.' . $sort, $order);
         }
     }
     // Overwrite limits only if they was set in criteria
     if (($firstResult = $criteria->getFirstResult()) !== null) {
         $qb->setFirstResult($firstResult);
     }
     if (($maxResults = $criteria->getMaxResults()) !== null) {
         $qb->setMaxResults($maxResults);
     }
 }
开发者ID:nmallare,项目名称:platform,代码行数:27,代码来源:QueryBuilderHelper.php


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