本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::getDqlPart方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getDqlPart方法的具体用法?PHP QueryBuilder::getDqlPart怎么用?PHP QueryBuilder::getDqlPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getDqlPart方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateDataSet_sort
public function testCreateDataSet_sort()
{
$request = $this->getBaseRequest();
$request->columnSorts = [0 => 'desc', 1 => 'asc'];
$dataSet = $this->dataSource->createDataSet($request);
$orderBy = $this->qb->getDqlPart('orderBy');
$this->assertEquals('p.name desc', $orderBy[0]->__toString());
$this->assertEquals('p.price asc', $orderBy[1]->__toString());
}
示例2: aliasExists
private function aliasExists($alias, QueryBuilder $qb)
{
$aliases = [];
foreach ($qb->getDqlPart('join') as $joins) {
foreach ($joins as $join) {
$aliases[] = $join->getAlias();
}
}
$aliases[] = $qb->getRootAlias();
return in_array($alias, $aliases);
}
示例3: retrieveExpressionByFieldName
private function retrieveExpressionByFieldName($fieldName)
{
/** @var $selectPart \Doctrine\ORM\Query\Expr\Select */
foreach ($this->qb->getDqlPart('select') as $selectPart) {
foreach ($selectPart->getParts() as $part) {
$pattern = "/^(.+) AS (?:|HIDDEN ){$fieldName}\$/i";
if (preg_match($pattern, $part, $matches)) {
return $matches[1];
}
}
}
throw new \InvalidArgumentException("Expression for field '{$fieldName}' could not be determined.");
}
示例4: 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();
}
示例5: checkIfQueryHasFetchJoin
/**
* @param QueryBuilder $qb
* @return boolean
*/
protected function checkIfQueryHasFetchJoin(QueryBuilder $qb)
{
$join = $qb->getDqlPart('join');
if (empty($join)) {
return false;
}
foreach ($join[$this->getTableAlias()] as $join) {
if ($join->getJoinType() === Join::INNER_JOIN || $join->getJoinType() === Join::LEFT_JOIN) {
return true;
}
}
return false;
}
示例6: getProductIdsInCategory
/**
* {@inheritdoc}
*/
public function getProductIdsInCategory(CategoryInterface $category, QueryBuilder $categoryQb = null)
{
$qb = $this->em->createQueryBuilder();
$qb->select('p.id');
$qb->from($this->entityName, 'p');
$qb->join('p.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());
}
$products = $qb->getQuery()->execute(array(), AbstractQuery::HYDRATE_ARRAY);
$productIds = array();
foreach ($products as $product) {
$productIds[] = $product['id'];
}
$productIds = array_unique($productIds);
return $productIds;
}