本文整理汇总了PHP中eZ\Publish\Core\Persistence\Database\SelectQuery::subSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::subSelect方法的具体用法?PHP SelectQuery::subSelect怎么用?PHP SelectQuery::subSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\Persistence\Database\SelectQuery
的用法示例。
在下文中一共展示了SelectQuery::subSelect方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Generate query expression for a Criterion this handler accepts
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Persistence\Legacy\Content\Search\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
* @throws RuntimeException
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion)
{
$column = $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link');
switch ($criterion->operator) {
case Criterion\Operator::CONTAINS:
if (count($criterion->value) > 1) {
$subRequest = array();
foreach ($criterion->value as $value) {
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('from_contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_link'));
$subSelect->innerJoin('ezcontentclass_attribute', $subSelect->expr->eq('ezcontentclass_attribute.id', 'ezcontentobject_link.contentclassattribute_id'));
$subSelect->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->eq($this->dbHandler->quoteColumn('contentclass_id', 'ezcontentclass_attribute'), $this->dbHandler->quoteColumn('contentclass_id', 'ezcontentobject')), $subSelect->expr->eq($this->dbHandler->quoteColumn('identifier', 'ezcontentclass_attribute'), $subSelect->bindValue($criterion->target)), $subSelect->expr->eq($column, $value)));
$subRequest[] = $subSelect->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
return $query->expr->lAnd($subRequest);
}
case Criterion\Operator::IN:
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('from_contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_link'));
$subSelect->innerJoin('ezcontentclass_attribute', $subSelect->expr->eq('ezcontentclass_attribute.id', 'ezcontentobject_link.contentclassattribute_id'));
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->eq($this->dbHandler->quoteColumn('contentclass_id', 'ezcontentclass_attribute'), $this->dbHandler->quoteColumn('contentclass_id', 'ezcontentobject')), $subSelect->expr->eq($this->dbHandler->quoteColumn('identifier', 'ezcontentclass_attribute'), $subSelect->bindValue($criterion->target)), $subSelect->expr->in($column, $criterion->value))));
default:
throw new RuntimeException("Unknown operator '{$criterion->operator}' for RelationList criterion handler.");
}
}
示例2: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $fieldFilters
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $fieldFilters = null)
{
/** @var \Netgen\TagsBundle\API\Repository\Values\Content\Query\Criterion\Value\TagKeywordValue $valueData */
$valueData = $criterion->valueData;
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('id', 'ezcontentobject'))->from($this->dbHandler->quoteTable('ezcontentobject'))->innerJoin($this->dbHandler->quoteTable('eztags_attribute_link'), $subSelect->expr->lAnd(array($subSelect->expr->eq($this->dbHandler->quoteColumn('objectattribute_version', 'eztags_attribute_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->eq($this->dbHandler->quoteColumn('object_id', 'eztags_attribute_link'), $this->dbHandler->quoteColumn('id', 'ezcontentobject')))))->innerJoin($this->dbHandler->quoteTable('eztags'), $subSelect->expr->eq($this->dbHandler->quoteColumn('keyword_id', 'eztags_attribute_link'), $this->dbHandler->quoteColumn('id', 'eztags')))->leftJoin($this->dbHandler->quoteTable('eztags_keyword'), $subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('id', 'eztags'), $this->dbHandler->quoteColumn('keyword_id', 'eztags_keyword')), $subSelect->expr->eq($this->dbHandler->quoteColumn('status', 'eztags_keyword'), $subSelect->bindValue(1, null, \PDO::PARAM_INT))));
if ($valueData !== null && !empty($valueData->languages)) {
if ($valueData->useAlwaysAvailable) {
$subSelect->where($subSelect->expr->lOr($subSelect->expr->in($this->dbHandler->quoteColumn('locale', 'eztags_keyword'), $valueData->languages), $subSelect->expr->eq($this->dbHandler->quoteColumn('main_language_id', 'eztags'), $subSelect->expr->bitAnd($this->dbHandler->quoteColumn('language_id', 'eztags_keyword'), -2))));
} else {
$subSelect->where($subSelect->expr->in($this->dbHandler->quoteColumn('locale', 'eztags_keyword'), $valueData->languages));
}
}
if ($criterion->operator == Criterion\Operator::LIKE) {
$subSelect->where($subSelect->expr->like($this->dbHandler->quoteColumn('keyword', 'eztags_keyword'), $subSelect->bindValue($criterion->value[0])));
} else {
$subSelect->where($subSelect->expr->in($this->dbHandler->quoteColumn('keyword', 'eztags_keyword'), $criterion->value));
}
$fieldDefinitionIds = $this->getSearchableFields($criterion->target);
if ($fieldDefinitionIds !== null) {
$subSelect->innerJoin($this->dbHandler->quoteTable('ezcontentobject_attribute'), $subSelect->expr->lAnd(array($subSelect->expr->eq($this->dbHandler->quoteColumn('id', 'ezcontentobject_attribute'), $this->dbHandler->quoteColumn('objectattribute_id', 'eztags_attribute_link')), $subSelect->expr->eq($this->dbHandler->quoteColumn('version', 'ezcontentobject_attribute'), $this->dbHandler->quoteColumn('objectattribute_version', 'eztags_attribute_link')))));
$subSelect->where($query->expr->in($this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_attribute'), $fieldDefinitionIds));
}
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例3: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @throws \RuntimeException
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
$column = $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link');
$fieldDefinitionIds = $this->getFieldDefinitionsIds($criterion->target);
switch ($criterion->operator) {
case Criterion\Operator::CONTAINS:
if (count($criterion->value) > 1) {
$subRequest = array();
foreach ($criterion->value as $value) {
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('from_contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_link'));
$subSelect->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->in($this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_link'), $fieldDefinitionIds), $subSelect->expr->eq($column, $value)));
$subRequest[] = $subSelect->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
return $query->expr->lAnd($subRequest);
}
// Intentionally omitting break
// Intentionally omitting break
case Criterion\Operator::IN:
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('from_contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_link'));
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->in($this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_link'), $fieldDefinitionIds), $subSelect->expr->in($column, $criterion->value))));
default:
throw new RuntimeException("Unknown operator '{$criterion->operator}' for RelationList criterion handler.");
}
}
示例4: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @todo: Needs optimisation since this subselect can potentially be problematic
* due to large number of contentobject_id values returned. One way to fix this
* is to use inner joins on ezcontentobject_tree table, but this is not currently
* supported in legacy search gateway
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
$subSelect = $query->subSelect();
if ($criterion->value[0] === Criterion\Visibility::VISIBLE) {
$expression = $query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('is_hidden', 'ezcontentobject_tree'), 0), $query->expr->eq($this->dbHandler->quoteColumn('is_invisible', 'ezcontentobject_tree'), 0));
} else {
$expression = $query->expr->lOr($query->expr->eq($this->dbHandler->quoteColumn('is_hidden', 'ezcontentobject_tree'), 1), $query->expr->eq($this->dbHandler->quoteColumn('is_invisible', 'ezcontentobject_tree'), 1));
}
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_tree'))->where($expression);
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例5: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Persistence\Legacy\Content\Search\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion)
{
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('id', 'ezcontentobject'))->from($this->dbHandler->quoteTable('ezcontentobject'))->innerJoin($this->dbHandler->quoteTable('eztags_attribute_link'), $subSelect->expr->lAnd(array($subSelect->expr->eq($this->dbHandler->quoteColumn('objectattribute_version', 'eztags_attribute_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->eq($this->dbHandler->quoteColumn('object_id', 'eztags_attribute_link'), $this->dbHandler->quoteColumn('id', 'ezcontentobject')))))->where($query->expr->in($this->dbHandler->quoteColumn('keyword_id', 'eztags_attribute_link'), $criterion->value));
$fieldDefinitionIds = $this->getSearchableFields($criterion->target);
if ($fieldDefinitionIds !== null) {
$subSelect->innerJoin($this->dbHandler->quoteTable('ezcontentobject_attribute'), $subSelect->expr->lAnd(array($subSelect->expr->eq($this->dbHandler->quoteColumn('id', 'ezcontentobject_attribute'), $this->dbHandler->quoteColumn('objectattribute_id', 'eztags_attribute_link')), $subSelect->expr->eq($this->dbHandler->quoteColumn('version', 'ezcontentobject_attribute'), $this->dbHandler->quoteColumn('objectattribute_version', 'eztags_attribute_link')))));
$subSelect->where($query->expr->in($this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_attribute'), $fieldDefinitionIds));
}
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例6: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
$idSet = array();
foreach ($criterion->value as $value) {
foreach (explode('/', trim($value, '/')) as $id) {
$idSet[$id] = true;
}
}
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_tree'))->where($query->expr->in($this->dbHandler->quoteColumn('node_id'), array_keys($idSet)));
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例7: handle
/**
* Generate query expression for a Criterion this handler accepts
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion)
{
switch ($criterion->target) {
case Criterion\UserMetadata::MODIFIER:
return $query->expr->in($this->dbHandler->quoteColumn("creator_id", "ezcontentobject_version"), $criterion->value);
case Criterion\UserMetadata::GROUP:
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn("contentobject_id", "t1"))->from($query->alias($this->dbHandler->quoteTable("ezcontentobject_tree"), "t1"))->innerJoin($query->alias($this->dbHandler->quoteTable("ezcontentobject_tree"), "t2"), $query->expr->like("t1.path_string", $query->expr->concat("t2.path_string", $query->bindValue("%"))))->where($query->expr->in($this->dbHandler->quoteColumn("contentobject_id", "t2"), $criterion->value));
return $query->expr->in($this->dbHandler->quoteColumn("owner_id", "ezcontentobject"), $subSelect);
case Criterion\UserMetadata::OWNER:
return $query->expr->in($this->dbHandler->quoteColumn("owner_id", "ezcontentobject"), $criterion->value);
}
throw new RuntimeException("Invalid target criterion encountered:'" . $criterion->target . "'");
}
示例8: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
switch ($criterion->target) {
case Criterion\UserMetadata::MODIFIER:
return $query->expr->in($this->dbHandler->quoteColumn('creator_id', 'ezcontentobject_version'), $criterion->value);
case Criterion\UserMetadata::GROUP:
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id', 't1'))->from($query->alias($this->dbHandler->quoteTable('ezcontentobject_tree'), 't1'))->innerJoin($query->alias($this->dbHandler->quoteTable('ezcontentobject_tree'), 't2'), $query->expr->like('t1.path_string', $query->expr->concat('t2.path_string', $query->bindValue('%'))))->where($query->expr->in($this->dbHandler->quoteColumn('contentobject_id', 't2'), $criterion->value));
return $query->expr->in($this->dbHandler->quoteColumn('owner_id', 'ezcontentobject'), $subSelect);
case Criterion\UserMetadata::OWNER:
return $query->expr->in($this->dbHandler->quoteColumn('owner_id', 'ezcontentobject'), $criterion->value);
}
throw new RuntimeException("Invalid target criterion encountered:'" . $criterion->target . "'");
}
示例9: handle
/**
* Generate query expression for a Criterion this handler accepts
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $fieldFilters
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $fieldFilters)
{
$subSelect = $query->subSelect();
switch ($criterion->operator) {
case Criterion\Operator::BETWEEN:
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_tree'))->where($query->expr->between($this->dbHandler->quoteColumn('priority'), $criterion->value[0], $criterion->value[1]));
break;
case Criterion\Operator::GT:
case Criterion\Operator::GTE:
case Criterion\Operator::LT:
case Criterion\Operator::LTE:
$operatorFunction = $this->comparatorMap[$criterion->operator];
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_tree'))->where($query->expr->{$operatorFunction}($this->dbHandler->quoteColumn('priority'), reset($criterion->value)));
}
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例10: handle
/**
* Generate query expression for a Criterion this handler accepts
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $fieldFilters
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $fieldFilters)
{
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_tree'))->where($query->expr->in($this->dbHandler->quoteColumn('node_id'), $criterion->value));
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例11: handle
/**
* Generate query expression for a Criterion this handler accepts
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion)
{
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('contentclass_id'))->from($this->dbHandler->quoteTable('ezcontentclass_classgroup'))->where($query->expr->in($this->dbHandler->quoteColumn('group_id'), $criterion->value));
return $query->expr->in($this->dbHandler->quoteColumn('contentclass_id', 'ezcontentobject'), $subSelect);
}
示例12: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotImplementedException If no searchable fields are found for the given criterion target.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
$fieldsInformation = $this->getFieldsInformation($criterion->target);
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_attribute'));
$whereExpressions = array();
foreach ($fieldsInformation as $fieldTypeIdentifier => $fieldsInfo) {
if ($fieldsInfo['column'] === false) {
throw new NotImplementedException("A field of type '{$fieldTypeIdentifier}' is not searchable in the legacy search engine.");
}
$filter = $this->fieldValueConverter->convertCriteria($fieldTypeIdentifier, $subSelect, $criterion, $fieldsInfo['column']);
$whereExpressions[] = $subSelect->expr->lAnd($subSelect->expr->in($this->dbHandler->quoteColumn('contentclassattribute_id'), $fieldsInfo['ids']), $filter);
}
$subSelect->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('version', 'ezcontentobject_attribute'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), count($whereExpressions) > 1 ? $subSelect->expr->lOr($whereExpressions) : $whereExpressions[0], $this->getFieldCondition($subSelect, $languageSettings)));
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例13: handle
/**
* Generate query expression for a Criterion this handler accepts
*
* accept() must be called before calling this method.
*
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target.
* @throws \RuntimeException If given criterion operator is not handled
*
* @param \eZ\Publish\Core\Persistence\Legacy\Content\Search\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion)
{
$this->checkSearchableFields($criterion->target);
$subSelect = $query->subSelect();
/** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion\Value\MapLocationValue $location */
$location = $criterion->valueData;
/**
* Note: this formula is precise only for short distances.
* @todo if ABS function was available in Zeta Database component it should be possible to account for
* distances across the date line. Revisit when Doctrine DBAL is introduced.
*/
$longitudeCorrectionByLatitude = pow(cos(deg2rad($location->latitude)), 2);
$distanceExpression = $subSelect->expr->add($subSelect->expr->mul($subSelect->expr->sub($this->dbHandler->quoteColumn("latitude", "ezgmaplocation"), $subSelect->bindValue($location->latitude)), $subSelect->expr->sub($this->dbHandler->quoteColumn("latitude", "ezgmaplocation"), $subSelect->bindValue($location->latitude))), $subSelect->expr->mul($subSelect->expr->sub($this->dbHandler->quoteColumn("longitude", "ezgmaplocation"), $subSelect->bindValue($location->longitude)), $subSelect->expr->sub($this->dbHandler->quoteColumn("longitude", "ezgmaplocation"), $subSelect->bindValue($location->longitude)), $subSelect->bindValue($longitudeCorrectionByLatitude)));
switch ($criterion->operator) {
case Criterion\Operator::IN:
case Criterion\Operator::EQ:
case Criterion\Operator::GT:
case Criterion\Operator::GTE:
case Criterion\Operator::LT:
case Criterion\Operator::LTE:
$operatorFunction = $this->comparatorMap[$criterion->operator];
$distanceInDegrees = pow($this->kilometersToDegrees($criterion->value), 2);
$distanceFilter = $subSelect->expr->{$operatorFunction}($distanceExpression, $subSelect->expr->round($subSelect->bindValue($distanceInDegrees), 10));
break;
case Criterion\Operator::BETWEEN:
$distanceInDegrees1 = pow($this->kilometersToDegrees($criterion->value[0]), 2);
$distanceInDegrees2 = pow($this->kilometersToDegrees($criterion->value[1]), 2);
$distanceFilter = $subSelect->expr->between($distanceExpression, $subSelect->expr->round($subSelect->bindValue($distanceInDegrees1), 10), $subSelect->expr->round($subSelect->bindValue($distanceInDegrees2), 10));
break;
default:
throw new RuntimeException('Unknown operator.');
}
// Calculate bounding box if possible
// @todo consider covering operators EQ and IN as well
$boundingConstraints = array();
switch ($criterion->operator) {
case Criterion\Operator::LT:
case Criterion\Operator::LTE:
$distanceUpper = $criterion->value;
break;
case Criterion\Operator::BETWEEN:
$distanceUpper = $criterion->value[0] > $criterion->value[1] ? $criterion->value[0] : $criterion->value[1];
break;
}
if (isset($distanceUpper)) {
$boundingConstraints = $this->getBoundingConstraints($subSelect, $location, $distanceUpper);
}
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_attribute'))->innerJoin($this->dbHandler->quoteTable("ezgmaplocation"), $subSelect->expr->lAnd(array($subSelect->expr->eq($this->dbHandler->quoteColumn("contentobject_version", "ezgmaplocation"), $this->dbHandler->quoteColumn("version", "ezcontentobject_attribute")), $subSelect->expr->eq($this->dbHandler->quoteColumn("contentobject_attribute_id", "ezgmaplocation"), $this->dbHandler->quoteColumn("id", "ezcontentobject_attribute"))), $boundingConstraints))->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('version', 'ezcontentobject_attribute'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $distanceFilter));
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}
示例14: handle
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
$subSelect = $query->subSelect();
$subSelect->select($this->dbHandler->quoteColumn('contentobject_id'))->from($this->dbHandler->quoteTable('ezsearch_object_word_link'))->where($query->expr->in($this->dbHandler->quoteColumn('word_id'), $this->getWordIdSubquery($subSelect, $criterion->value)));
return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
}