/** * @var Directed $edge * @return void */ protected function addJoins() { foreach ($this->walk->getEdges() as $edge) { $relation = $edge->getLayoutAttribute('label'); $this->builder->innerJoin($this->aliases->get($edge->getVertexStart()->getId()) . '.' . $relation, $this->aliases->get($edge->getVertexEnd()->getId())); } }
/** * Inner join * * @param string $join * @param string $alias * * @return DoctrineEnvironment */ public function innerJoin($join, $alias) { if (!in_array($alias, $this->joins)) { $this->queryBuilder->innerJoin($join, $alias); array_push($this->joins, $alias); } return $this; }
private function queryKeyword(QueryBuilder $qb, $keyword) { // Actor filter $qb->innerJoin('LocDVDAPIBundle:Actor', 'act', 'WITH', $qb->expr()->eq('act.mapper', 'tvZod.mapper')); // Summary filter $qb->innerJoin('LocDVDAPIBundle:Summary', 'summary', 'WITH', $qb->expr()->eq('tvZod.mapper', 'summary.mapper')); // Title Tvshow filter $qb->innerJoin('tvZod.tvshow', 'tv'); // Title TvZod filter $qb->andWhere($qb->expr()->orX($qb->expr()->like('tvZod.tagLine', ':keyword'), $qb->expr()->like('summary.summary', ':keyword'), $qb->expr()->like('tv.title', ':keyword'), $qb->expr()->like('act.actor', ':keyword'))); $qb->setParameter('keyword', '%' . $keyword . '%'); return $qb; }
/** * {@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; }
public function filter(QueryBuilder $queryBuilder, $metadata, $option) { if (!isset($option['field']) || !$option['field']) { // @codeCoverageIgnoreStart throw new Exception('Field must be specified for inner join'); } // @codeCoverageIgnoreEnd if (!isset($option['alias']) || !$option['alias']) { // @codeCoverageIgnoreStart throw new Exception('Alias must be specified for inner join'); } // @codeCoverageIgnoreEnd if (!isset($option['parentAlias']) || !$option['parentAlias']) { $option['parentAlias'] = 'row'; } if (!isset($option['conditionType']) && isset($option['condition'])) { throw new Exception('A conditionType must be specified for a condition'); } if (!isset($option['condition']) && isset($option['conditionType'])) { throw new Exception('A condition must be specified for a conditionType'); } if (!isset($option['conditionType'])) { $option['conditionType'] = null; } if (!isset($option['condition'])) { $option['condition'] = null; } if (!isset($option['indexBy'])) { $option['indexBy'] = null; } $queryBuilder->innerJoin($option['parentAlias'] . '.' . $option['field'], $option['alias'], $option['conditionType'], $option['condition'], $option['indexBy']); }
/** * Parse order conditions and add it to query * * @param string|null $sort * @param string|null $order */ public function orderBy($sort = null, $order = null) { if (is_string($sort)) { if (strpos($sort, '.') > 0) { $parts = explode('.', $sort); if (count($parts) >= 2 && array_key_exists($parts[0], $this->metadata->associationMappings)) { $this->qBuilder->innerJoin('e.' . $parts[0], $parts[0], Join::WITH); $this->qBuilder->orderBy($parts[0] . '.' . $parts[1], $order); } } else { if (array_key_exists($sort, $this->metadata->fieldMappings)) { $this->qBuilder->orderBy('e.' . $sort, $order); } } } }
/** * {@inheritDoc} */ public function buildQuery(QueryBuilder $qb, array $query) { if (isset($query['owner_id'])) { $userAlias = $this->createAlias(); $qb->innerJoin('Omeka\\Entity\\Property.owner', $userAlias); $qb->andWhere($qb->expr()->eq("{$userAlias}.id", $this->createNamedParameter($qb, $query['owner_id']))); } if (isset($query['vocabulary_id'])) { $vocabularyAlias = $this->createAlias(); $qb->innerJoin('Omeka\\Entity\\Property.vocabulary', $vocabularyAlias); $qb->andWhere($qb->expr()->eq("{$vocabularyAlias}.id", $this->createNamedParameter($qb, $query['vocabulary_id']))); } if (isset($query['vocabulary_namespace_uri'])) { $vocabularyAlias = $this->createAlias(); $qb->innerJoin('Omeka\\Entity\\Property.vocabulary', $vocabularyAlias); $qb->andWhere($qb->expr()->eq("{$vocabularyAlias}.namespaceUri", $this->createNamedParameter($qb, $query['vocabulary_namespace_uri']))); } if (isset($query['vocabulary_prefix'])) { $vocabularyAlias = $this->createAlias(); $qb->innerJoin('Omeka\\Entity\\Property.vocabulary', $vocabularyAlias); $qb->andWhere($qb->expr()->eq("{$vocabularyAlias}.prefix", $this->createNamedParameter($qb, $query['vocabulary_prefix']))); } if (isset($query['local_name'])) { $qb->andWhere($qb->expr()->eq("Omeka\\Entity\\Property.localName", $this->createNamedParameter($qb, $query['local_name']))); } if (isset($query['term']) && $this->isTerm($query['term'])) { list($prefix, $localName) = explode(':', $query['term']); $vocabularyAlias = $this->createAlias(); $qb->innerJoin('Omeka\\Entity\\Property.vocabulary', $vocabularyAlias); $qb->andWhere($qb->expr()->eq("{$vocabularyAlias}.prefix", $this->createNamedParameter($qb, $prefix))); $qb->andWhere($qb->expr()->eq("Omeka\\Entity\\Property.localName", $this->createNamedParameter($qb, $localName))); } }
/** * Return the default loader object. * * @param ObjectManager $manager * @param QueryBuilder $queryBuilder * @param string $class * * @return EntityLoaderInterface */ public function getLoader(ObjectManager $manager, $queryBuilder, $class) { $queryBuilder->innerJoin(NodeVersion::class, 'nv', Join::WITH, 'nv.refId = e.id and nv.refEntityName = :ref_name'); $queryBuilder->innerJoin(NodeTranslation::class, 'nt', Join::WITH, 'nt.id = nv.nodeTranslation and nt.publicNodeVersion = nv.id'); $queryBuilder->innerJoin(Node::class, 'n', Join::WITH, 'n.id = nt.node'); $queryBuilder->andWhere($queryBuilder->expr()->eq("n.deleted", 0)); $queryBuilder->andWhere($queryBuilder->expr()->eq('nt.online', 1)); $queryBuilder->setParameter("ref_name", $class); if (null !== $queryBuilder->getParameter('left') && null !== $queryBuilder->getParameter('right')) { $queryBuilder->andWhere('n.lft >= :left')->andWhere('n.rgt <= :right'); } if (null !== $queryBuilder->getParameter('lang')) { $queryBuilder->andWhere('nt.lang = :lang'); } return new ORMQueryBuilderLoader($queryBuilder, $manager, $class); }
protected function applyCriteria(QueryBuilder $queryBuilder, array $criteria = null) { if (isset($criteria['groups'])) { $queryBuilder->innerJoin($this->getAlias() . '.machine', 'm', 'WITH', $this->getAlias() . '.machine = m.id')->innerJoin('m.groups', 'g', 'WITH', $queryBuilder->expr()->andX($queryBuilder->expr()->in('g.id', $criteria['groups']))); unset($criteria['groups']); } parent::applyCriteria($queryBuilder, $criteria); }
/** * {@inheritdoc} */ protected function addJoinStatement($joinType, $join, $joinAlias, $joinConditionType, $joinCondition) { if ('left' === $joinType) { $this->qb->leftJoin($join, $joinAlias, $joinConditionType, $joinCondition); } else { $this->qb->innerJoin($join, $joinAlias, $joinConditionType, $joinCondition); } }
/** * {@inheritdoc} */ protected function applyCriteria(QueryBuilder $queryBuilder, array $criteria = null) { if (isset($criteria['channels'])) { $queryBuilder->innerJoin('o.channels', 'channel')->andWhere('channel = :channel')->setParameter('channel', $criteria['channels']); unset($criteria['channels']); } parent::applyCriteria($queryBuilder, $criteria); }
/** * {@inheritdoc} */ protected function prepareQuery(QueryBuilder $query, $rootAlias, $alias, $itemsType) { $entityId = $this->requestParams->get(self::ENTITY_PARAM, 0); $query->where($rootAlias . '.mode <> :mode'); $query->setParameter('mode', ConfigModelManager::MODE_HIDDEN); $query->innerJoin($rootAlias . '.entity', 'ce', 'WITH', 'ce.id=' . $entityId); $query->addSelect('ce.id as entity_id'); return parent::prepareQuery($query, $rootAlias, $alias, $itemsType); }
/** * {@inheritdoc} */ public function apply(ResourceInterface $resource, QueryBuilder $queryBuilder, Request $request) { if (!$request->query->has('tags')) { return; } foreach ($request->query->get('tags') as $i => $tag) { $queryBuilder->innerJoin($queryBuilder->getRootAliases()[0] . '.tags', 't' . $i)->andWhere('t' . $i . '.name = :name_' . $i)->setParameter('name_' . $i, $tag); } }
/** * Evaluates inner joins * * @param QueryBuilder $queryBuilder Query builder * @param AnnotationPaginator $annotation Annotation * * @return PaginatorEvaluatorInterface self Object */ public function evaluate(QueryBuilder $queryBuilder, AnnotationPaginator $annotation) { if (is_array($annotation->getInnerJoins())) { foreach ($annotation->getInnerJoins() as $innerJoin) { $queryBuilder->innerJoin(trim($innerJoin[0]) . '.' . trim($innerJoin[1]), trim($innerJoin[2])); if (isset($innerJoin[3]) && $innerJoin[3]) { $queryBuilder->addSelect(trim($innerJoin[2])); } } } return $this; }
/** * Create query object * * @return \Doctrine\ORM\QueryBuilder */ public function createQuery() { $offset = ($this->_options->getPage() - 1) * $this->_options->getRows(); if (!($this->_qb = $this->_options->getCustomQueryBuilder())) { $this->_qb = $this->getEntityManager()->createQueryBuilder(); } $this->_qb->select($this->getAlias()); $this->_qb->from($this->getEntityClass(), $this->getAlias()); if ($joins = $this->getOptions()->getJoins()) { foreach ($joins as $index => $join) { $placeHolder = ':p' . $join['field'] . $index; $this->_qb->innerJoin($this->getAlias() . '.' . $join['field'], $join['alias'])->andWhere($join['alias'] . '.id = ' . $placeHolder)->setParameter($placeHolder, $join['key']); } } if ($itemCountPerPage = $this->_options->getRows()) { $this->_qb->setMaxResults($itemCountPerPage); } if ($offset) { $this->_qb->setFirstResult($offset); } if ($presets = $this->_options->getPresets()) { $this->addPresets($presets); } $filter = $this->_options->getFilters(); if (is_array($filter) && array_key_exists('field', $filter) && array_key_exists('value', $filter) && array_key_exists('expression', $filter) && array_key_exists('options', $filter)) { $this->filter($filter['field'], $filter['value'], $filter['expression'], $filter['options']); } if ($treeFilter = $this->_options->getTreeFilter()) { $this->buildTreeFilterQuery($treeFilter); } $sort = $this->_options->getSortOrder(); if (is_array($sort)) { $c = 0; foreach ($sort as $s) { if (!empty($s['sidx'])) { $field = $s['sidx']; $direction = isset($s['sord']) ? $s['sord'] : 'asc'; if ($c) { $this->_qb->addOrderBy($this->getAlias() . '.' . $field, $direction); } else { $this->_qb->orderBy($this->getAlias() . '.' . $field, $direction); } $c++; } } } if ($subGridFilter = $this->_options->getSubGridFilter()) { foreach ($subGridFilter as $field => $value) { $this->_qb->andWhere($this->_qb->expr()->eq($this->getAlias() . '.' . $field, $value)); } } return $this->_qb; }
/** * {@inheritdoc} * @return QueryBuilder */ public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null) { if ($condition !== NULL) { $beforeArgs = array_slice(func_get_args(), 3); $args = array_values(Helpers::separateParameters($this, $beforeArgs)); if (count($beforeArgs) > count($args)) { $indexBy = count($args) === 2 ? $args[1] : NULL; $condition = $args[0]; } } return parent::innerJoin($join, $alias, $conditionType, $condition, $indexBy); }
protected function preparePhoneCondition(QueryBuilder $qb, PropertyPhoneInterface $condition, $alias) { if ($condition->getPhone()) { $qb->innerJoin($alias . '.phones', 'p'); $number = preg_replace('/^(?:\\+7|\\+?8)|[\\(\\)\\-\\s\\W]+/', '', $condition->getPhone()); $qb->andWhere($qb->expr()->like('p.number', ':number'))->setParameter('number', '%' . $number . '%'); } else { if ($condition->getPhoneNotSpecified()) { $qb->leftJoin($alias . '.phones', 'p'); $qb->andWhere($qb->expr()->isNull('p.id')); } } }
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'); }
function it_adds_binary_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->innerJoin('p.values', Argument::any(), 'WITH', Argument::any())->shouldBeCalled(); $this->addAttributeFilter($number, '=', 12); }
protected function prepareQuery(QueryBuilder $queryBuilder) { $expr = $queryBuilder->expr(); if (count($this->filteredMailingLists)) { $queryBuilder->innerJoin('r.subscriptions', 's'); $or = $expr->orX(); foreach ($this->filteredMailingLists as $index => $mailingList) { $or->add($expr->eq('s.mailingList', ':mailingList' . $index)); $queryBuilder->setParameter('mailingList' . $index, $mailingList->getId()); } $queryBuilder->andWhere($or); } if (count($this->filteredProperties)) { foreach ($this->filteredProperties as $index => $filteredProperty) { $property = 'r.' . $filteredProperty['recipientsPropertyFilter_property']; $comparator = $filteredProperty['recipientsPropertyFilter_comparator']; $value = $filteredProperty['recipientsPropertyFilter_value']; switch ($comparator) { case 'empty': $queryBuilder->andWhere($expr->orX($expr->eq($property, ':property' . $index), $expr->isNull($property))); $value = ''; break; case 'not empty': $queryBuilder->andWhere($expr->gt($property, ':property' . $index)); $value = ''; break; case 'eq': $queryBuilder->andWhere($expr->eq($property, ':property' . $index)); break; case 'neq': $queryBuilder->andWhere($expr->neq($property, ':property' . $index)); break; case 'gt': $queryBuilder->andWhere($expr->gt($property, ':property' . $index)); break; case 'gte': $queryBuilder->andWhere($expr->gte($property, ':property' . $index)); break; case 'lt': $queryBuilder->andWhere($expr->lt($property, ':property' . $index)); break; case 'lte': $queryBuilder->andWhere($expr->lte($property, ':property' . $index)); break; } $queryBuilder->setParameter(':property' . $index, $value); } } }
/** * @param QueryBuilder $qb * @param array $value */ protected function addJoin(QueryBuilder $qb, $value) { $defaultValues = ['conditionType' => null, 'condition' => null]; if (isset($value['join'])) { if (isset($value['join']['inner'])) { foreach ((array) $value['join']['inner'] as $join) { $join = array_merge($defaultValues, $join); $qb->innerJoin($join['join'], $join['alias'], $join['conditionType'], $join['condition']); } } if (isset($value['join']['left'])) { foreach ((array) $value['join']['left'] as $join) { $join = array_merge($defaultValues, $join); $qb->leftJoin($join['join'], $join['alias'], $join['conditionType'], $join['condition']); } } } }
/** * @return \Doctrine\ORM\QueryBuilder */ private function createQueryBuilder() { $this->queryBuilder = $this->em->createQueryBuilder()->from($this->entityName, $this->entityName); foreach ($this->getJoins() as $entity => $join) { switch ($join->getJoinMethod()) { case DoctrineJoinDescriptor::JOIN_METHOD_LEFT: $this->queryBuilder->leftJoin($join->getJoin(), $entity, $join->getJoinConditionMethod(), $join->getJoinCondition()); break; case DoctrineJoinDescriptor::JOIN_METHOD_INNER: $this->queryBuilder->innerJoin($join->getJoin(), $entity, $join->getJoinConditionMethod(), $join->getJoinCondition()); break; } } // set where if (!empty($this->whereFields)) { $this->addWheres($this->whereFields, $this->whereValues, self::WHERE_COMPARATOR_EQUAL); } // set where not if (!empty($this->whereNotFields)) { $this->addWheres($this->whereNotFields, $this->whereNotValues, self::WHERE_COMPARATOR_UNEQUAL); } if (!empty($this->groupByFields)) { foreach ($this->groupByFields as $fields) { $this->queryBuilder->groupBy($fields->getSelect()); } } // set in if (!empty($this->inFields)) { $this->addIns($this->inFields, $this->inValues); } // set between if (!empty($this->betweenFields)) { $this->addBetweens($this->betweenFields, $this->betweenValues); } if ($this->search != null) { $searchParts = []; foreach ($this->searchFields as $searchField) { $searchParts[] = $searchField->getSelect() . ' LIKE :search'; } $this->queryBuilder->andWhere('(' . implode(' OR ', $searchParts) . ')'); $this->queryBuilder->setParameter('search', '%' . $this->search . '%'); } return $this->queryBuilder; }
/** * Joins with the authorizations and filters the results to keep only those authorized. * * @param QueryBuilder $qb * @param SecurityIdentityInterface $identity * @param string $action * @param string|null $entityClass Class name of the entity that is the resource in the query. * If omitted, it will be guessed from the SELECT. * @param string|null $entityAlias Alias of the entity that is the resource in the query. * If omitted, it will be guessed from the SELECT. * * @throws \RuntimeException The query builder has no "select" part */ public static function joinACL(QueryBuilder $qb, SecurityIdentityInterface $identity, $action, $entityClass = null, $entityAlias = null) { if ($entityClass === null) { $rootEntities = $qb->getRootEntities(); if (!isset($rootEntities[0])) { throw new \RuntimeException('The query builder has no "select" part'); } $entityClass = $rootEntities[0]; } if ($entityAlias === null) { $rootAliases = $qb->getRootAliases(); if (!isset($rootAliases[0])) { throw new \RuntimeException('The query builder has no "select" part'); } $entityAlias = $rootAliases[0]; } $qb->innerJoin('MyCLabs\\ACL\\Model\\Authorization', 'authorization', 'WITH', $entityAlias . '.id = authorization.entityId'); $qb->andWhere('authorization.entityClass = :acl_entity_class'); $qb->andWhere('authorization.securityIdentity = :acl_identity'); $qb->andWhere('authorization.actions.' . $action . ' = true'); $qb->setParameter('acl_identity', $identity); $qb->setParameter('acl_entity_class', $entityClass); }
function it_adds_a_not_equal_attribute_filter_in_the_query($attrValidatorHelper, QueryBuilder $queryBuilder, AttributeInterface $sku, Expr $expr, Expr\Comparison $comp, Expr\Literal $literal) { $attrValidatorHelper->validateLocale($sku, Argument::any())->shouldBeCalled(); $attrValidatorHelper->validateScope($sku, Argument::any())->shouldBeCalled(); $sku->getId()->willReturn(42); $sku->getCode()->willReturn('sku'); $sku->getBackendType()->willReturn('varchar'); $sku->isLocalizable()->willReturn(false); $sku->isScopable()->willReturn(false); $queryBuilder->expr()->willReturn($expr); $queryBuilder->getRootAlias()->willReturn('p'); $expr->literal('My Sku')->willReturn($literal); $expr->notLike(Argument::any(), 'My Sku')->shouldBeCalled()->willReturn($comp); $literal->__toString()->willReturn('My Sku'); $comp->__toString()->willReturn('filtersku.varchar NOT LIKE "My Sku"'); $queryBuilder->innerJoin(Argument::any(), Argument::any(), 'WITH', Argument::containingString('.attribute = 42 AND filtersku.varchar NOT LIKE "My Sku"'))->shouldBeCalled(); $this->addAttributeFilter($sku, '!=', 'My Sku', null, null, ['field' => 'sku']); }
function it_adds_a_greater_than_filter_on_an_attribute_to_the_query(AttributeInterface $attribute, $attrValidatorHelper, QueryBuilder $qb, Expr $expr, Expr\Comparison $comparison) { $attrValidatorHelper->validateLocale($attribute, Argument::any())->shouldBeCalled(); $attrValidatorHelper->validateScope($attribute, Argument::any())->shouldBeCalled(); $qb->getRootAlias()->willReturn('p'); $attribute->getBackendType()->willReturn('backend_type'); $attribute->getCode()->willReturn('code'); $attribute->getId()->willReturn(42); $attribute->isLocalizable()->willReturn(false); $attribute->isScopable()->willReturn(false); $qb->expr()->willReturn($expr); $expr->literal('2014-03-15')->willReturn('code'); $expr->literal('en_US')->willReturn('code'); $expr->literal('mobile')->willReturn('code'); $expr->gt(Argument::any(), 'code')->willReturn($comparison)->shouldBeCalledTimes(2); $comparison->__toString()->willReturn(); $qb->innerJoin('p.values', Argument::any(), 'WITH', Argument::any())->shouldBeCalledTimes(2); $this->addAttributeFilter($attribute, '>', '2014-03-15'); $this->addAttributeFilter($attribute, '>', new \DateTime('2014-03-15')); }
public function buildNameQuery(Builder $qb, $query = null) { if (!isset($query)) { $query = $this->getRequest()->getQuery('description'); } $filters = ['attributeDesc']; if ($query) { $where = []; $params = []; $i = 0; foreach ($filters as $condition) { if (isset($query[$condition])) { if (is_array($query[$condition])) { $uValues = []; foreach ($query[$condition] as $values) { if (is_array($values)) { $uValues = array_merge($uValues, $values); } else { $uValues = array_merge($uValues, [$values]); } } $uValues = array_unique($uValues); $boolX = count($uValues) > 1 ? $qb->expr()->andX() : $qb->expr()->orX(); foreach ($query[$condition] as $criteria => $values) { $qb->innerJoin('e.attributes', 'v' . $i); $qb->innerJoin('v' . $i . '.attribute', 'a' . $i); $qb->andWhere('a' . $i . '.active = 1'); switch ($condition) { case 'attributeDesc': $expr = $qb->expr(); $andX = $expr->andX(); $where["desc_{$i}"] = "%{$criteria}%"; $andX->add($expr->like("a" . $i . ".attributeDesc", ":desc_{$i}")); if ($values && is_array($values)) { $j = 0; $_orX = $qb->expr()->orX(); foreach ($values as $value) { $where["value_{$j}"] = "%{$value}%"; $_orX->add($expr->like("v" . $i . ".value", ":value_{$j}")); $j++; } $andX->add($_orX); } else { $where["value_{$i}"] = "%{$values}%"; $andX->add($expr->like("v" . $i . ".value", ":value_{$i}")); } $boolX->add($andX); $i++; break; } } if ($boolX->getParts()) { $qb->andWhere($boolX); } } } elseif ("" !== $query[$condition]) { $qb->innerJoin('e.attributes', 'v'); $qb->innerJoin('v.attribute', 'a'); switch ($condition) { case 'attributeDesc': $where['attributeDesc'] = "%{$query[$condition]}%"; $qb->andWhere("a.attributeDesc LIKE :attributeDesc"); break; } } } if ($where) { foreach ($where as $key => $value) { $qb->setParameter($key, $value); } } } return $qb; }
public function buildQuery(QueryBuilder $qb, array $query) { if (isset($query['owner_id'])) { $userAlias = $this->createAlias(); $qb->innerJoin('Omeka\\Entity\\Site.owner', $userAlias); $qb->andWhere($qb->expr()->eq("{$userAlias}.id", $this->createNamedParameter($qb, $query['owner_id']))); } }
/** * Prepare certain search condition * * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare * @param integer $value Condition data OPTIONAL * * @return void */ protected function prepareCndCurrency(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) { if ($value) { $queryBuilder->innerJoin('o.currency', 'currency', 'WITH', 'currency.currency_id = :currency_id')->setParameter('currency_id', $value); } }
public function it_uses_local_alias_if_global_was_not_set(QueryBuilder $qb) { $this->beConstructedWith('user', 'authUser'); $qb->innerJoin('b.user', 'authUser')->shouldBeCalled(); $this->modify($qb, 'b'); }
public function applyGreatestNPerGroupDate(QueryBuilder $qb) { $qb->distinct(); $qb2 = $this->createQueryBuilder('ss')->select('MAX(ss.timestamp)')->where('DATE(ss.timestamp) = DATE(s.timestamp)'); $qb->innerJoin($this->getEntityName(), 'sub', 'WITH', $qb->expr()->eq('s.timestamp', '(' . $qb2->getDQL() . ')')); }