本文整理汇总了PHP中Doctrine\ORM\Query\QueryException::invalidParameterNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryException::invalidParameterNumber方法的具体用法?PHP QueryException::invalidParameterNumber怎么用?PHP QueryException::invalidParameterNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query\QueryException
的用法示例。
在下文中一共展示了QueryException::invalidParameterNumber方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _doExecute
/**
* {@inheritdoc}
*/
protected function _doExecute()
{
$executor = $this->_parse()->getSqlExecutor();
if ($this->_queryCacheProfile) {
$executor->setQueryCacheProfile($this->_queryCacheProfile);
}
// Prepare parameters
$paramMappings = $this->_parserResult->getParameterMappings();
if (count($paramMappings) != count($this->_params)) {
throw QueryException::invalidParameterNumber();
}
list($sqlParams, $types) = $this->processParameterMappings($paramMappings);
if ($this->_resultSetMapping === null) {
$this->_resultSetMapping = $this->_parserResult->getResultSetMapping();
}
return $executor->execute($this->_em->getConnection(), $sqlParams, $types);
}
示例2: _doExecute
/**
* {@inheritdoc}
*/
protected function _doExecute()
{
$executor = $this->_parse()->getSqlExecutor();
// Prepare parameters
$paramMappings = $this->_parserResult->getParameterMappings();
if (count($paramMappings) != count($this->_params)) {
throw QueryException::invalidParameterNumber();
}
$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];
}
}
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(get_class($value))) {
$values = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
$sqlPositions = $paramMappings[$key];
$sqlParams = array_merge($sqlParams, array_combine((array) $sqlPositions, $values));
} else {
foreach ($paramMappings[$key] as $position) {
$sqlParams[$position] = $value;
}
}
}
if ($sqlParams) {
ksort($sqlParams);
$sqlParams = array_values($sqlParams);
}
if ($this->_resultSetMapping === null) {
$this->_resultSetMapping = $this->_parserResult->getResultSetMapping();
}
return $executor->execute($this->_em->getConnection(), $sqlParams, $types);
}
示例3: _doExecute
/**
* {@inheritdoc}
*/
protected function _doExecute()
{
$executor = $this->_parse()->getSqlExecutor();
// Prepare parameters
$paramMappings = $this->_parserResult->getParameterMappings();
if (count($paramMappings) != count($this->_params)) {
throw QueryException::invalidParameterNumber();
}
$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];
}
}
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(get_class($value))) {
if ($this->_em->getUnitOfWork()->getEntityState($value) == UnitOfWork::STATE_MANAGED) {
$idValues = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
} else {
$class = $this->_em->getClassMetadata(get_class($value));
$idValues = $class->getIdentifierValues($value);
}
$sqlPositions = $paramMappings[$key];
$cSqlPos = count($sqlPositions);
$cIdValues = count($idValues);
$idValues = array_values($idValues);
for ($i = 0; $i < $cSqlPos; $i++) {
$sqlParams[$sqlPositions[$i]] = $idValues[$i % $cIdValues];
}
} else {
foreach ($paramMappings[$key] as $position) {
$sqlParams[$position] = $value;
}
}
}
if ($sqlParams) {
ksort($sqlParams);
$sqlParams = array_values($sqlParams);
}
if ($this->_resultSetMapping === null) {
$this->_resultSetMapping = $this->_parserResult->getResultSetMapping();
}
return $executor->execute($this->_em->getConnection(), $sqlParams, $types);
}
示例4: _doExecute
/**
* {@inheritdoc}
*/
protected function _doExecute()
{
$executor = $this->_parse()->getSqlExecutor();
if ($this->_queryCacheProfile) {
$executor->setQueryCacheProfile($this->_queryCacheProfile);
}
if ($this->_resultSetMapping === null) {
$this->_resultSetMapping = $this->_parserResult->getResultSetMapping();
}
// Prepare parameters
$paramMappings = $this->_parserResult->getParameterMappings();
if (count($paramMappings) != count($this->parameters)) {
throw QueryException::invalidParameterNumber();
}
// evict all cache for the entity region
if ($this->hasCache && isset($this->_hints[self::HINT_CACHE_EVICT]) && $this->_hints[self::HINT_CACHE_EVICT]) {
$this->evictEntityCacheRegion();
}
list($sqlParams, $types) = $this->processParameterMappings($paramMappings);
return $executor->execute($this->_em->getConnection(), $sqlParams, $types);
}
示例5: _prepareParams
/**
* {@inheritdoc}
*
* @override
*/
protected function _prepareParams(array $params)
{
$sqlParams = array();
$paramMappings = $this->_parserResult->getParameterMappings();
if (count($paramMappings) != count($params)) {
throw QueryException::invalidParameterNumber();
}
foreach ($params as $key => $value) {
if (!isset($paramMappings[$key])) {
throw QueryException::unknownParameter($key);
}
if (is_object($value)) {
//$values = $this->_em->getClassMetadata(get_class($value))->getIdentifierValues($value);
$values = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
//var_dump($this->_em->getUnitOfWork()->getEntityIdentifier($value));
$sqlPositions = $paramMappings[$key];
$sqlParams = array_merge($sqlParams, array_combine((array) $sqlPositions, $values));
} else {
if (is_bool($value)) {
$boolValue = $this->_em->getConnection()->getDatabasePlatform()->convertBooleans($value);
foreach ($paramMappings[$key] as $position) {
$sqlParams[$position] = $boolValue;
}
} else {
foreach ($paramMappings[$key] as $position) {
$sqlParams[$position] = $value;
}
}
}
}
ksort($sqlParams);
return array_values($sqlParams);
}