本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::getRootAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getRootAlias方法的具体用法?PHP QueryBuilder::getRootAlias怎么用?PHP QueryBuilder::getRootAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getRootAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFieldSorter
/**
* {@inheritdoc}
*/
public function addFieldSorter($field, $direction, $locale = null, $scope = null)
{
$this->qb->addOrderBy($field, $direction);
$idField = $this->qb->getRootAlias() . '.id';
$this->qb->addOrderBy($idField);
return $this;
}
示例2: addFieldSorter
/**
* {@inheritdoc}
*/
public function addFieldSorter($field, $direction, $locale = null, $scope = null)
{
$alias = 'inGroupSorter';
$inGroupExpr = 'CASE WHEN :currentGroup MEMBER OF p.groups THEN true ELSE false END';
$this->qb->addSelect(sprintf('%s AS %s', $inGroupExpr, $alias))->addOrderBy($alias, $direction);
$idField = $this->qb->getRootAlias() . '.id';
$this->qb->addOrderBy($idField);
return $this;
}
示例3: addFieldSorter
/**
* {@inheritdoc}
*/
public function addFieldSorter($field, $direction, $locale = null, $scope = null)
{
$alias = 'sorterCompleteness';
$util = new CompletenessJoin($this->qb);
$util->addJoins($alias, $locale, $scope);
$this->qb->addOrderBy($alias . '.ratio', $direction);
$idField = $this->qb->getRootAlias() . '.id';
$this->qb->addOrderBy($idField);
return $this;
}
示例4: addJoins
/**
* Add completeness joins to query builder
*
* @param string $completenessAlias the join alias
* @param string $locale the locale
* @param sting $scope the scope
*
* @return CompletenessJoin
*/
public function addJoins($completenessAlias, $locale, $scope)
{
$rootAlias = $this->qb->getRootAlias();
$localeAlias = $completenessAlias . 'Locale';
$channelAlias = $completenessAlias . 'Channel';
$rootEntity = current($this->qb->getRootEntities());
$completenessMapping = $this->qb->getEntityManager()->getClassMetadata($rootEntity)->getAssociationMapping('completenesses');
$completenessClass = $completenessMapping['targetEntity'];
$this->qb->leftJoin('PimCatalogBundle:Locale', $localeAlias, 'WITH', $localeAlias . '.code = :cLocaleCode')->leftJoin('PimCatalogBundle:Channel', $channelAlias, 'WITH', $channelAlias . '.code = :cScopeCode')->leftJoin($completenessClass, $completenessAlias, 'WITH', $completenessAlias . '.locale = ' . $localeAlias . '.id AND ' . $completenessAlias . '.channel = ' . $channelAlias . '.id AND ' . $completenessAlias . '.product = ' . $rootAlias . '.id')->setParameter('cLocaleCode', $locale)->setParameter('cScopeCode', $scope);
return $this;
}
示例5: addFieldSorter
/**
* {@inheritdoc}
*/
public function addFieldSorter($field, $direction)
{
$rootAlias = $this->qb->getRootAlias();
$prefix = 'sorter';
$field = $prefix . 'familyLabel';
$family = $prefix . 'family';
$trans = $prefix . 'familyTranslations';
$this->qb->leftJoin($rootAlias . '.family', $family)->leftJoin($family . '.translations', $trans, 'WITH', $trans . '.locale = :dataLocale');
$this->qb->addSelect('COALESCE(' . $trans . '.label, CONCAT(\'[\', ' . $family . '.code, \']\')) as ' . $field);
$this->qb->addOrderBy($field, $direction);
return $this;
}
示例6: addAttributeFilter
/**
* {@inheritdoc}
*/
public function addAttributeFilter(AbstractAttribute $attribute, $operator, $value)
{
$joinAlias = 'filter' . $attribute->getCode() . $this->aliasCounter++;
$backendField = sprintf('%s.%s', $joinAlias, $attribute->getBackendType());
if ($operator === 'EMPTY') {
$this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias));
$this->qb->andWhere($this->prepareCriteriaCondition($backendField, $operator, $value));
} else {
$condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias);
$condition .= ' AND ' . $this->prepareCriteriaCondition($backendField, $operator, $value);
$this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
}
return $this;
}
示例7: addAttributeSorter
/**
* {@inheritdoc}
*/
public function addAttributeSorter(AttributeInterface $attribute, $direction, $locale = null, $scope = null)
{
$aliasPrefix = 'sorter';
$joinAlias = $aliasPrefix . 'V' . $attribute->getCode();
$backendType = $attribute->getBackendType();
// join to value
$condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
$this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
$joinAliasMetric = $aliasPrefix . 'M' . $attribute->getCode();
$this->qb->leftJoin($joinAlias . '.' . $backendType, $joinAliasMetric);
$this->qb->addOrderBy($joinAliasMetric . '.baseData', $direction);
$idField = $this->qb->getRootAlias() . '.id';
$this->qb->addOrderBy($idField);
return $this;
}
示例8: sort
/**
* Sets sorting.
* @param array $sorting
*/
public function sort(array $sorting)
{
foreach ($sorting as $key => $value) {
$column = isset($this->sortMapping[$key]) ? $this->sortMapping[$key] : $this->qb->getRootAlias() . '.' . $key;
$this->qb->addOrderBy($column, $value);
}
}
示例9: entityJoin
/**
* {@inheritdoc}
*/
public function entityJoin(array $associationMappings)
{
$alias = $this->queryBuilder->getRootAlias();
$newAlias = 's';
$joinedEntities = $this->queryBuilder->getDQLPart('join');
foreach ($associationMappings as $associationMapping) {
// Do not add left join to already joined entities with custom query
foreach ($joinedEntities as $joinExprList) {
foreach ($joinExprList as $joinExpr) {
$newAliasTmp = $joinExpr->getAlias();
if (sprintf('%s.%s', $alias, $associationMapping['fieldName']) === $joinExpr->getJoin()) {
$this->entityJoinAliases[] = $newAliasTmp;
$alias = $newAliasTmp;
continue 3;
}
}
}
$newAlias .= '_' . $associationMapping['fieldName'];
if (!in_array($newAlias, $this->entityJoinAliases)) {
$this->entityJoinAliases[] = $newAlias;
$this->queryBuilder->leftJoin(sprintf('%s.%s', $alias, $associationMapping['fieldName']), $newAlias);
}
$alias = $newAlias;
}
return $alias;
}
示例10: getFieldName
/**
* {@inheritdoc}
*/
private function getFieldName($field)
{
if (false === strpos($field, '.')) {
return $this->queryBuilder->getRootAlias() . '.' . $field;
}
return $field;
}
示例11: addAttributeSorter
/**
* {@inheritdoc}
*/
public function addAttributeSorter(AbstractAttribute $attribute, $direction)
{
$aliasPrefix = 'sorter';
$joinAlias = $aliasPrefix . 'V' . $attribute->getCode() . $this->aliasCounter++;
$backendType = $attribute->getBackendType();
// join to value and sort on
$condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias);
// Remove current join in order to put the orderBy related join
// at first place in the join queue for performances reasons
$joinsSet = $this->qb->getDQLPart('join');
$this->qb->resetDQLPart('join');
$this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
$this->qb->addOrderBy($joinAlias . '.' . $backendType, $direction);
// Reapply previous join after the orderBy related join
$this->applyJoins($joinsSet);
return $this;
}
示例12: __construct
/**
* @param \Doctrine\ORM\QueryBuilder $qb
* @param string $searchfield search field for IN query, uses rootAlias.id by default [optional]
*/
public function __construct(QueryBuilder $qb, $searchfield = null)
{
$this->qb = $qb;
if (null !== $searchfield) {
$this->searchfield = $searchfield;
} else {
$this->searchfield = $qb->getRootAlias() . '.id';
}
}
示例13: 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);
}
示例14: Expr
function it_adds_a_like_filter_in_the_query(QueryBuilder $queryBuilder, AbstractAttribute $sku)
{
$sku->getId()->willReturn(42);
$sku->getCode()->willReturn('sku');
$sku->getBackendType()->willReturn('varchar');
$sku->isLocalizable()->willReturn(false);
$sku->isScopable()->willReturn(false);
$queryBuilder->expr()->willReturn(new Expr());
$queryBuilder->getRootAlias()->willReturn('p');
$condition = "filtersku1.attribute = 42 AND filtersku1.varchar LIKE 'My Sku'";
$queryBuilder->innerJoin('p.values', 'filtersku1', 'WITH', $condition)->shouldBeCalled();
$this->addAttributeFilter($sku, 'LIKE', 'My Sku');
}
示例15: Expr
function it_adds_empty_filter_in_the_query($attrValidatorHelper, QueryBuilder $queryBuilder, AttributeInterface $number)
{
$attrValidatorHelper->validateLocale($number, Argument::any())->shouldBeCalled();
$attrValidatorHelper->validateScope($number, Argument::any())->shouldBeCalled();
$number->getId()->willReturn(42);
$number->getCode()->willReturn('number');
$number->getBackendType()->willReturn('varchar');
$number->isLocalizable()->willReturn(false);
$number->isScopable()->willReturn(false);
$queryBuilder->expr()->willReturn(new Expr());
$queryBuilder->getRootAlias()->willReturn('p');
$queryBuilder->leftJoin('p.values', Argument::any(), 'WITH', Argument::any())->shouldBeCalled();
$queryBuilder->andWhere(Argument::any())->shouldBeCalled();
$this->addAttributeFilter($number, 'EMPTY', 12);
}