本文整理匯總了PHP中Doctrine\ORM\Query\QueryException::parameterTypeMissmatch方法的典型用法代碼示例。如果您正苦於以下問題:PHP QueryException::parameterTypeMissmatch方法的具體用法?PHP QueryException::parameterTypeMissmatch怎麽用?PHP QueryException::parameterTypeMissmatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\Query\QueryException
的用法示例。
在下文中一共展示了QueryException::parameterTypeMissmatch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processParameterMappings
/**
* @param Query $query
* @param array $paramMappings
* @return array
* @throws \Doctrine\ORM\Query\QueryException
*/
protected function processParameterMappings(Query $query, $paramMappings)
{
$sqlParams = array();
$types = array();
/** @var Parameter $parameter */
foreach ($query->getParameters() as $parameter) {
$key = $parameter->getName();
if (!isset($paramMappings[$key])) {
throw QueryException::unknownParameter($key);
}
$value = $query->processParameterValue($parameter->getValue());
$type = $parameter->getValue() === $value ? $parameter->getType() : Query\ParameterTypeInferer::inferType($value);
foreach ($paramMappings[$key] as $position) {
$types[$position] = $type;
}
$sqlPositions = $paramMappings[$key];
$value = array($value);
$countValue = count($value);
for ($i = 0, $l = count($sqlPositions); $i < $l; $i++) {
$sqlParams[$sqlPositions[$i]] = $value[$i % $countValue];
}
}
if (count($sqlParams) != count($types)) {
throw QueryException::parameterTypeMissmatch();
}
if ($sqlParams) {
ksort($sqlParams);
$sqlParams = array_values($sqlParams);
ksort($types);
$types = array_values($types);
}
return array($sqlParams, $types);
}
示例2: processParameterMappings
/**
* Processes query parameter mappings
*
* @param array $paramMappings
* @return array
*/
private function processParameterMappings($paramMappings)
{
$sqlParams = $types = array();
foreach ($this->_params as $key => $value) {
if (!isset($paramMappings[$key])) {
throw QueryException::unknownParameter($key);
}
if (isset($this->_paramTypes[$key])) {
foreach ($paramMappings[$key] as $position) {
$types[$position] = $this->_paramTypes[$key];
}
}
$sqlPositions = $paramMappings[$key];
// optimized multi value sql positions away for now,
// they are not allowed in DQL anyways.
$value = array($value);
$countValue = count($value);
for ($i = 0, $l = count($sqlPositions); $i < $l; $i++) {
$sqlParams[$sqlPositions[$i]] = $value[$i % $countValue];
}
}
if (count($sqlParams) != count($types)) {
throw QueryException::parameterTypeMissmatch();
}
if ($sqlParams) {
ksort($sqlParams);
$sqlParams = array_values($sqlParams);
ksort($types);
$types = array_values($types);
}
return array($sqlParams, $types);
}