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


PHP Query::setParameters方法代码示例

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


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

示例1: __construct

 /**
  * @param \Doctrine\ORM\Query $query          The Doctrine Query
  * @param array               $fields         Fields to export
  * @param string              $dateTimeFormat
  */
 public function __construct(Query $query, array $fields, $dateTimeFormat = 'r')
 {
     $this->query = clone $query;
     $this->query->setParameters($query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $this->query->setHint($name, $value);
     }
     $this->propertyAccessor = PropertyAccess::createPropertyAccessor();
     $this->propertyPaths = array();
     foreach ($fields as $name => $field) {
         if (is_string($name) && is_string($field)) {
             $this->propertyPaths[$name] = new PropertyPath($field);
         } else {
             $this->propertyPaths[$field] = new PropertyPath($field);
         }
     }
     $this->dateTimeFormat = $dateTimeFormat;
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:23,代码来源:DoctrineORMQuerySourceIterator.php

示例2: __construct

 /**
  * @param \Doctrine\ORM\Query $query          The Doctrine Query
  * @param array               $fields         Fields to export
  * @param string              $dateTimeFormat
  */
 public function __construct(Query $query, array $fields, $dateTimeFormat = 'r')
 {
     $this->query = clone $query;
     $this->query->setParameters($query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $this->query->setHint($name, $value);
     }
     // Note : will be deprecated in Symfony 3.0, conserved for 2.2 compatibility
     // Use createPropertyAccessor() for 3.0
     // @see Symfony\Component\PropertyAccess\PropertyAccess
     $this->propertyAccessor = PropertyAccess::getPropertyAccessor();
     $this->propertyPaths = array();
     foreach ($fields as $name => $field) {
         if (is_string($name) && is_string($field)) {
             $this->propertyPaths[$name] = new PropertyPath($field);
         } else {
             $this->propertyPaths[$field] = new PropertyPath($field);
         }
     }
     $this->dateTimeFormat = $dateTimeFormat;
 }
开发者ID:serialken,项目名称:BugTracker,代码行数:26,代码来源:DoctrineORMQuerySourceIterator.php

示例3: testCalculateCount

 /**
  * @param string $dql
  * @param string $expectedCountQuery
  * @param array  $sqlParameters
  * @param array  $types
  * @param array  $queryParameters
  *
  * @dataProvider getCountDataProvider
  */
 public function testCalculateCount($dql, $expectedCountQuery, array $sqlParameters = [], array $types = [], array $queryParameters = [])
 {
     /** @var $entityManager EntityManager|\PHPUnit_Framework_MockObject_MockObject */
     /** @var $connection Connection|\PHPUnit_Framework_MockObject_MockObject */
     /** @var $statement Statement|\PHPUnit_Framework_MockObject_MockObject */
     list($entityManager, $connection, $statement) = $this->prepareMocks();
     $query = new Query($entityManager);
     $query->setDQL($dql);
     $query->setParameters($queryParameters);
     $connection->expects($this->once())->method('executeQuery')->with($expectedCountQuery, $sqlParameters, $types)->will($this->returnValue($statement));
     $statement->expects($this->any())->method('fetch')->will($this->onConsecutiveCalls(['sclr_0' => self::TEST_COUNT], false));
     $statement->expects($this->any())->method('fetchColumn')->will($this->returnValue(self::TEST_COUNT));
     $this->assertEquals(self::TEST_COUNT, QueryCountCalculator::calculateCount($query));
 }
开发者ID:northdakota,项目名称:platform,代码行数:23,代码来源:QueryCountCalculatorTest.php

示例4: testCalculateCount

 /**
  * @param string $dql
  * @param array $sqlParameters
  * @param array $types
  * @param array $queryParameters
  *
  * @dataProvider getCountDataProvider
  */
 public function testCalculateCount($dql, array $sqlParameters, array $types, array $queryParameters = array())
 {
     /** @var $entityManager EntityManager|\PHPUnit_Framework_MockObject_MockObject */
     /** @var $connection Connection|\PHPUnit_Framework_MockObject_MockObject */
     /** @var $statement Statement|\PHPUnit_Framework_MockObject_MockObject */
     list($entityManager, $connection, $statement) = $this->prepareMocks();
     $query = new Query($entityManager);
     $query->setDQL($dql);
     $query->setParameters($queryParameters);
     $expectedSql = 'SELECT COUNT(*) FROM (' . $query->getSQL() . ') AS e';
     $connection->expects($this->once())->method('executeQuery')->with($expectedSql, $sqlParameters, $types)->will($this->returnValue($statement));
     $statement->expects($this->once())->method('fetchColumn')->with()->will($this->returnValue(self::TEST_COUNT));
     $this->assertEquals(self::TEST_COUNT, QueryCountCalculator::calculateCount($query));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:22,代码来源:CountCalculatorTest.php

示例5: getStatisticListTotalCount

 /**
  * Helper function returns total count of the passed query builder
  *
  * @param \Doctrine\ORM\Query $dataQuery
  * @return int|null
  */
 private function getStatisticListTotalCount(\Doctrine\ORM\Query $dataQuery)
 {
     //userCurrencyFactor has not to be part of the count parameters
     $originalParameters = $dataQuery->getParameters();
     $countParameters = new \Doctrine\Common\Collections\ArrayCollection();
     /** @var \Doctrine\ORM\Query\Parameter $parameter */
     foreach ($originalParameters as $parameter) {
         if ($parameter->getName() === 'userCurrencyFactor') {
             continue;
         }
         $countParameters->add($parameter);
     }
     $dataQuery->setParameters($countParameters);
     $totalCount = Shopware()->Models()->getQueryCount($dataQuery);
     $dataQuery->setParameters($originalParameters);
     return $totalCount;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:23,代码来源:Partner.php


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