本文整理汇总了PHP中eZ\Publish\Core\Persistence\Database\SelectQuery::bindValue方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::bindValue方法的具体用法?PHP SelectQuery::bindValue怎么用?PHP SelectQuery::bindValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\Persistence\Database\SelectQuery
的用法示例。
在下文中一共展示了SelectQuery::bindValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFieldCondition
/**
* Returns a field language join condition for the given $languageSettings.
*
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param array $languageSettings
*
* @return string
*/
protected function getFieldCondition(SelectQuery $query, array $languageSettings)
{
// 1. Use main language(s) by default
if (empty($languageSettings['languages'])) {
return $query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn('initial_language_id', 'ezcontentobject'), $this->dbHandler->quoteColumn('language_id', 'ezcontentobject_attribute')), $query->bindValue(0, null, PDO::PARAM_INT));
}
// 2. Otherwise use prioritized languages
$leftSide = $query->expr->bitAnd($query->expr->sub($this->dbHandler->quoteColumn('language_mask', 'ezcontentobject'), $query->expr->bitAnd($this->dbHandler->quoteColumn('language_mask', 'ezcontentobject'), $this->dbHandler->quoteColumn('language_id', 'ezcontentobject_attribute'))), $query->bindValue(1, null, PDO::PARAM_INT));
$rightSide = $query->expr->bitAnd($this->dbHandler->quoteColumn('language_id', 'ezcontentobject_attribute'), $query->bindValue(1, null, PDO::PARAM_INT));
for ($index = count($languageSettings['languages']) - 1, $multiplier = 2; $index >= 0; $index--, $multiplier *= 2) {
$languageId = $this->languageHandler->loadByLanguageCode($languageSettings['languages'][$index])->id;
$addToLeftSide = $query->expr->bitAnd($query->expr->sub($this->dbHandler->quoteColumn('language_mask', 'ezcontentobject'), $query->expr->bitAnd($this->dbHandler->quoteColumn('language_mask', 'ezcontentobject'), $this->dbHandler->quoteColumn('language_id', 'ezcontentobject_attribute'))), $languageId);
$addToRightSide = $query->expr->bitAnd($this->dbHandler->quoteColumn('language_id', 'ezcontentobject_attribute'), $languageId);
if ($multiplier > $languageId) {
$factor = $multiplier / $languageId;
for ($shift = 0; $factor > 1; $factor = $factor / 2, $shift++) {
}
$factorTerm = ' << ' . $shift;
$addToLeftSide .= $factorTerm;
$addToRightSide .= $factorTerm;
} elseif ($multiplier < $languageId) {
$factor = $languageId / $multiplier;
for ($shift = 0; $factor > 1; $factor = $factor / 2, $shift++) {
}
$factorTerm = ' >> ' . $shift;
$addToLeftSide .= $factorTerm;
$addToRightSide .= $factorTerm;
}
$leftSide = $query->expr->add($leftSide, "({$addToLeftSide})");
$rightSide = $query->expr->add($rightSide, "({$addToRightSide})");
}
return $query->expr->lAnd($query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn('language_mask', 'ezcontentobject'), $this->dbHandler->quoteColumn('language_id', 'ezcontentobject_attribute')), $query->bindValue(0, null, PDO::PARAM_INT)), $query->expr->lt($leftSide, $rightSide));
}
示例2: handle
/**
* Generates query expression for operator and value of a Field Criterion.
*
* @throws \RuntimeException If operator is not handled.
*
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param string $column
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(SelectQuery $query, Criterion $criterion, $column)
{
$column = $this->dbHandler->quoteColumn($column);
switch ($criterion->operator) {
case Criterion\Operator::IN:
$filter = $query->expr->in($column, array_map(array($this, 'lowercase'), $criterion->value));
break;
case Criterion\Operator::BETWEEN:
$filter = $query->expr->between($column, $query->bindValue($this->lowercase($criterion->value[0])), $query->bindValue($this->lowercase($criterion->value[1])));
break;
case Criterion\Operator::EQ:
case Criterion\Operator::GT:
case Criterion\Operator::GTE:
case Criterion\Operator::LT:
case Criterion\Operator::LTE:
case Criterion\Operator::LIKE:
$operatorFunction = $this->comparatorMap[$criterion->operator];
$filter = $query->expr->{$operatorFunction}($column, $query->bindValue($this->lowercase($criterion->value)));
break;
case Criterion\Operator::CONTAINS:
$filter = $query->expr->like($column, $query->bindValue("%" . $this->lowercase($criterion->value) . "%"));
break;
default:
throw new RuntimeException("Unknown operator '{$criterion->operator}' for Field criterion handler.");
}
return $filter;
}
示例3: 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)
{
$column = $this->dbHandler->quoteColumn('is_invisible', 'ezcontentobject_tree');
switch ($criterion->value[0]) {
case Criterion\Visibility::VISIBLE:
return $query->expr->eq($column, $query->bindValue(0, null, PDO::PARAM_INT));
case Criterion\Visibility::HIDDEN:
return $query->expr->eq($column, $query->bindValue(1, null, PDO::PARAM_INT));
default:
throw new RuntimeException("Unknown value '{$criterion->value[0]}' for Visibility criterion handler.");
}
}
示例4: handle
/**
* Generates query expression for operator and value of a Field Criterion.
*
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param string $column
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(SelectQuery $query, Criterion $criterion, $column)
{
switch ($criterion->operator) {
case Criterion\Operator::CONTAINS:
$quotedColumn = $this->dbHandler->quoteColumn($column);
$value = $this->lowerCase($criterion->value);
$filter = $query->expr->lOr(array($query->expr->eq($quotedColumn, $query->bindValue($value, null, \PDO::PARAM_STR)), $query->expr->like($quotedColumn, $query->bindValue("%" . $this->separator . $value, null, \PDO::PARAM_STR)), $query->expr->like($quotedColumn, $query->bindValue($value . $this->separator . "%", null, \PDO::PARAM_STR)), $query->expr->like($quotedColumn, $query->bindValue("%" . $this->separator . $value . $this->separator . "%", null, \PDO::PARAM_STR))));
break;
default:
$filter = parent::handle($query, $criterion, $column);
}
return $filter;
}
示例5: 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)
{
$column = $this->dbHandler->quoteColumn('priority');
switch ($criterion->operator) {
case Criterion\Operator::BETWEEN:
return $query->expr->between($column, $query->bindValue($criterion->value[0]), $query->bindValue($criterion->value[1]));
case Criterion\Operator::GT:
case Criterion\Operator::GTE:
case Criterion\Operator::LT:
case Criterion\Operator::LTE:
$operatorFunction = $this->comparatorMap[$criterion->operator];
return $query->expr->{$operatorFunction}($column, $query->bindValue(reset($criterion->value)));
default:
throw new RuntimeException("Unknown operator '{$criterion->operator}' for Priority criterion handler.");
}
}
示例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)
{
$statements = array();
foreach ($criterion->value as $pattern) {
$statements[] = $query->expr->like($this->dbHandler->quoteColumn('path_string', 'ezcontentobject_tree'), $query->bindValue($pattern . '%'));
}
return $query->expr->lOr($statements);
}
示例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)
{
$column = $this->dbHandler->quoteColumn($criterion->target === Criterion\DateMetadata::MODIFIED ? 'modified' : 'published', 'ezcontentobject');
switch ($criterion->operator) {
case Criterion\Operator::IN:
return $query->expr->in($column, $criterion->value);
case Criterion\Operator::BETWEEN:
return $query->expr->between($column, $query->bindValue($criterion->value[0]), $query->bindValue($criterion->value[1]));
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];
return $query->expr->{$operatorFunction}($column, $query->bindValue(reset($criterion->value)));
default:
throw new RuntimeException("Unknown operator '{$criterion->operator}' for DateMetadata criterion handler.");
}
}
示例8: 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)
{
$table = $this->getUniqueTableName();
$statements = array();
foreach ($criterion->value as $pattern) {
$statements[] = $query->expr->like($this->dbHandler->quoteColumn('path_string', $table), $query->bindValue($pattern . '%'));
}
$query->leftJoin($query->alias($this->dbHandler->quoteTable('ezcontentobject_tree'), $this->dbHandler->quoteIdentifier($table)), $query->expr->eq($this->dbHandler->quoteColumn('contentobject_id', $table), $this->dbHandler->quoteColumn('id', 'ezcontentobject')));
return $query->expr->lOr($statements);
}
示例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 $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
{
$column = $this->dbHandler->quoteColumn('depth', 'ezcontentobject_tree');
switch ($criterion->operator) {
case Criterion\Operator::IN:
return $query->expr->in($column, $criterion->value);
case Criterion\Operator::BETWEEN:
return $query->expr->between($column, $query->bindValue($criterion->value[0]), $query->bindValue($criterion->value[1]));
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];
return $query->expr->{$operatorFunction}($column, $query->bindValue(reset($criterion->value)));
default:
throw new RuntimeException("Unknown operator '{$criterion->operator}' for Depth criterion handler.");
}
}
示例10: addFieldFiltersConditions
/**
* Adds field filters condition to the WHERE clause of the given $query.
*
* Conditions are combined with existing ones using logical AND operator.
*
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param array $fieldFilters
*/
protected function addFieldFiltersConditions(SelectQuery $query, array $fieldFilters)
{
$languageMask = $this->getFieldFiltersLanguageMask($fieldFilters);
// Only apply if languages are defined in $fieldFilters;
// 'useAlwaysAvailable' does not make sense on its own
if ($languageMask === null) {
return;
}
// Condition for the language part of $fieldFilters
$languageMaskExpression = $query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn("language_id", "ezcontentobject_attribute"), $query->bindValue($languageMask, null, \PDO::PARAM_INT)), $query->bindValue(0, null, \PDO::PARAM_INT));
// If 'useAlwaysAvailable' is set to true, additionally factor in condition for the
// Content's main language that is marked as always available
if (!isset($fieldFilters["useAlwaysAvailable"]) || $fieldFilters["useAlwaysAvailable"] === true) {
$query->where($query->expr->lOr($languageMaskExpression, $query->expr->lAnd($query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn("language_id", "ezcontentobject_attribute"), $this->dbHandler->quoteColumn("initial_language_id", "ezcontentobject")), $query->bindValue(0, null, \PDO::PARAM_INT)), $query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn("language_id", "ezcontentobject_attribute"), $query->bindValue(1, null, \PDO::PARAM_INT)), $query->bindValue(0, null, \PDO::PARAM_INT)))));
} else {
// Matching on a given list of languages
$query->where($languageMaskExpression);
}
}
示例11: getWordExpression
/**
* Get single word query expression
*
* Depending on the configuration of the full text search criterion
* converter wildcards are either transformed into the respective LIKE
* queries, or everything is just compared using equal.
*
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param string $token
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
protected function getWordExpression(SelectQuery $query, $token)
{
if ($this->configuration['enableWildcards'] && $token[0] === '*') {
return $query->expr->like($this->dbHandler->quoteColumn('word'), $query->bindValue('%' . substr($token, 1)));
}
if ($this->configuration['enableWildcards'] && $token[strlen($token) - 1] === '*') {
return $query->expr->like($this->dbHandler->quoteColumn('word'), $query->bindValue(substr($token, 0, -1) . '%'));
}
return $query->expr->eq($this->dbHandler->quoteColumn('word'), $query->bindValue($token));
}
示例12: handle
/**
* Generates query expression for operator and value of a Field Criterion.
*
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param string $column
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(SelectQuery $query, Criterion $criterion, $column)
{
switch ($criterion->operator) {
case Criterion\Operator::CONTAINS:
$filter = $query->expr->eq($this->dbHandler->quoteColumn($column), $query->bindValue($this->lowerCase($criterion->value)));
break;
default:
$filter = parent::handle($query, $criterion, $column);
}
return $filter;
}
示例13: 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)
{
$table = $this->getUniqueTableName();
$column = $this->dbHandler->quoteColumn('depth', $table);
$query->leftJoin($query->alias($this->dbHandler->quoteTable('ezcontentobject_tree'), $this->dbHandler->quoteIdentifier($table)), $query->expr->eq($this->dbHandler->quoteColumn('contentobject_id', $table), $this->dbHandler->quoteColumn('id', 'ezcontentobject')));
switch ($criterion->operator) {
case Criterion\Operator::IN:
return $query->expr->in($column, $criterion->value);
case Criterion\Operator::BETWEEN:
return $query->expr->between($column, $query->bindValue($criterion->value[0]), $query->bindValue($criterion->value[1]));
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];
return $query->expr->{$operatorFunction}($column, $query->bindValue(reset($criterion->value)));
default:
throw new RuntimeException("Unknown operator '{$criterion->operator}' for Depth criterion handler.");
}
}
示例14: applyJoin
/**
* Applies joins to the query, required to fetch sort data.
*
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
* @param int $number
* @param array $languageSettings
*/
public function applyJoin(SelectQuery $query, SortClause $sortClause, $number, array $languageSettings)
{
/** @var \eZ\Publish\API\Repository\Values\Content\Query\SortClause\Target\FieldTarget $fieldTarget */
$fieldTarget = $sortClause->targetData;
$fieldMap = $this->contentTypeHandler->getSearchableFieldMap();
if (!isset($fieldMap[$fieldTarget->typeIdentifier][$fieldTarget->fieldIdentifier]['field_definition_id'])) {
throw new InvalidArgumentException('$sortClause->targetData', 'No searchable fields found for the given sort clause target ' . "'{$fieldTarget->fieldIdentifier}' on '{$fieldTarget->typeIdentifier}'.");
}
$fieldDefinitionId = $fieldMap[$fieldTarget->typeIdentifier][$fieldTarget->fieldIdentifier]['field_definition_id'];
$table = $this->getSortTableName($number);
$externalTable = $this->getSortTableName($number, 'ezgmaplocation');
$query->leftJoin($query->alias($this->dbHandler->quoteTable('ezcontentobject_attribute'), $this->dbHandler->quoteIdentifier($table)), $query->expr->lAnd($query->expr->eq($query->bindValue($fieldDefinitionId, null, PDO::PARAM_INT), $this->dbHandler->quoteColumn('contentclassattribute_id', $table)), $query->expr->eq($this->dbHandler->quoteColumn('contentobject_id', $table), $this->dbHandler->quoteColumn('id', 'ezcontentobject')), $query->expr->eq($this->dbHandler->quoteColumn('version', $table), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $this->getFieldCondition($query, $languageSettings, $table)))->leftJoin($query->alias($this->dbHandler->quoteTable('ezgmaplocation'), $this->dbHandler->quoteIdentifier($externalTable)), $query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('contentobject_version', $externalTable), $this->dbHandler->quoteColumn('version', $table)), $query->expr->eq($this->dbHandler->quoteColumn('contentobject_attribute_id', $externalTable), $this->dbHandler->quoteColumn('id', $table))));
}
示例15: 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 . "'");
}