當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。