/** * 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) { $subexpressions = array(); foreach ($criterion->criteria as $subCriterion) { $subexpressions[] = $converter->convertCriteria($query, $subCriterion); } return $query->expr->lAnd($subexpressions); }
/** * Get query condition * * @param Criterion $filter * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query * @param mixed $translations * * @return string */ protected function getQueryCondition(Criterion $filter, SelectQuery $query, $translations) { $condition = $query->expr->lAnd($this->criteriaConverter->convertCriteria($query, $filter), $query->expr->eq('ezcontentobject.status', ContentInfo::STATUS_PUBLISHED), $query->expr->eq('ezcontentobject_version.status', VersionInfo::STATUS_PUBLISHED)); if ($translations === null) { return $condition; } $translationQuery = $query->subSelect(); $translationQuery->select($this->handler->quoteColumn('contentobject_id'))->from($this->handler->quoteTable('ezcontentobject_attribute'))->where($translationQuery->expr->in($this->handler->quoteColumn('language_code'), $translations)); return $query->expr->lAnd($condition, $query->expr->in($this->handler->quoteColumn('id'), $translationQuery)); }
/** * Returns total results count for $criterion and $sortClauses * * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion * @param null|\eZ\Publish\API\Repository\Values\Content\Query\SortClause[] $sortClauses * * @return array */ protected function getTotalCount(Criterion $criterion, $sortClauses) { $query = $this->handler->createSelectQuery(); $query->select($query->alias($query->expr->count('*'), 'count'))->from($this->handler->quoteTable('ezcontentobject_tree'))->innerJoin('ezcontentobject', 'ezcontentobject_tree.contentobject_id', 'ezcontentobject.id')->innerJoin('ezcontentobject_version', 'ezcontentobject.id', 'ezcontentobject_version.contentobject_id'); if ($sortClauses !== null) { $this->sortClauseConverter->applyJoin($query, $sortClauses); } $query->where($this->criteriaConverter->convertCriteria($query, $criterion), $query->expr->eq('ezcontentobject.status', $query->bindValue(1, null, PDO::PARAM_INT)), $query->expr->eq('ezcontentobject_version.status', $query->bindValue(1, null, PDO::PARAM_INT)), $query->expr->neq($this->handler->quoteColumn("depth"), $query->bindValue(0, null, PDO::PARAM_INT))); $statement = $query->prepare(); $statement->execute(); $res = $statement->fetchAll(PDO::FETCH_ASSOC); return (int) $res[0]['count']; }
/** * 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) { return $query->expr->not($converter->convertCriteria($query, $criterion->criteria[0])); }