本文整理汇总了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;
}
示例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;
}
示例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));
}
示例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));
}
示例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;
}