本文整理汇总了PHP中Doctrine\ORM\ORMException::cantUseInOperatorOnCompositeKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP ORMException::cantUseInOperatorOnCompositeKeys方法的具体用法?PHP ORMException::cantUseInOperatorOnCompositeKeys怎么用?PHP ORMException::cantUseInOperatorOnCompositeKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\ORMException
的用法示例。
在下文中一共展示了ORMException::cantUseInOperatorOnCompositeKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSelectConditionStatementSQL
/**
* {@inheritdoc}
*/
public function getSelectConditionStatementSQL($field, $value, $assoc = null, $comparison = null)
{
$selectedColumns = array();
$columns = $this->getSelectConditionStatementColumnSQL($field, $assoc);
if (count($columns) > 1 && $comparison === Comparison::IN) {
/*
* @todo try to support multi-column IN expressions.
* Example: (col1, col2) IN (('val1A', 'val2A'), ('val1B', 'val2B'))
*/
throw ORMException::cantUseInOperatorOnCompositeKeys();
}
foreach ($columns as $column) {
$placeholder = '?';
if (isset($this->class->fieldMappings[$field]['requireSQLConversion'])) {
$placeholder = Type::getType($this->class->getTypeOfField($field))->convertToDatabaseValueSQL($placeholder, $this->platform);
}
if (null !== $comparison) {
// special case null value handling
if (($comparison === Comparison::EQ || $comparison === Comparison::IS) && null === $value) {
$selectedColumns[] = $column . ' IS NULL';
continue;
}
if ($comparison === Comparison::NEQ && null === $value) {
$selectedColumns[] = $column . ' IS NOT NULL';
continue;
}
$selectedColumns[] = $column . ' ' . sprintf(self::$comparisonMap[$comparison], $placeholder);
continue;
}
if (is_array($value)) {
$in = sprintf('%s IN (%s)', $column, $placeholder);
if (false !== array_search(null, $value, true)) {
$selectedColumns[] = sprintf('(%s OR %s IS NULL)', $in, $column);
continue;
}
$selectedColumns[] = $in;
continue;
}
if (null === $value) {
$selectedColumns[] = sprintf('%s IS NULL', $column);
continue;
}
$selectedColumns[] = sprintf('%s = %s', $column, $placeholder);
}
return implode(' AND ', $selectedColumns);
}