本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::innerJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::innerJoin方法的具体用法?PHP QueryBuilder::innerJoin怎么用?PHP QueryBuilder::innerJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::innerJoin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addJoins
/**
* @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()));
}
}
示例2: innerJoin
/**
* 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;
}
示例3: queryKeyword
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;
}
示例4: 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;
}
示例5: filter
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']);
}
示例6: orderBy
/**
* 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);
}
}
}
}
示例7: buildQuery
/**
* {@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)));
}
}
示例8: getLoader
/**
* 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);
}
示例9: applyCriteria
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);
}
示例10: addJoinStatement
/**
* {@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);
}
}
示例11: applyCriteria
/**
* {@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);
}
示例12: prepareQuery
/**
* {@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);
}
示例13: apply
/**
* {@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);
}
}
示例14: evaluate
/**
* 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;
}
示例15: createQuery
/**
* 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;
}