当前位置: 首页>>代码示例>>PHP>>正文


PHP Query::processParameterValue方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Query::processParameterValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::processParameterValue方法的具体用法?PHP Query::processParameterValue怎么用?PHP Query::processParameterValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Query的用法示例。


在下文中一共展示了Query::processParameterValue方法的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);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:39,代码来源:QueryCountCalculator.php

示例2: processParameterMappings

 /**
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  *
  * Copy of Doctrine\ORM\Query::processParameterMappings
  *
  * @param Query $query
  * @return array
  * @throws QueryException
  */
 public function processParameterMappings(Query $query)
 {
     $parser = new Parser($query);
     $parseResult = $parser->parse();
     $paramMappings = $parseResult->getParameterMappings();
     $resultSetMapping = $parseResult->getResultSetMapping();
     $paramCount = count($query->getParameters());
     $mappingCount = count($paramMappings);
     if ($paramCount > $mappingCount) {
         throw QueryException::tooManyParameters($mappingCount, $paramCount);
     } elseif ($paramCount < $mappingCount) {
         throw QueryException::tooFewParameters($mappingCount, $paramCount);
     }
     $sqlParams = [];
     $types = [];
     foreach ($query->getParameters() as $parameter) {
         $key = $parameter->getName();
         $value = $parameter->getValue();
         $rsm = $resultSetMapping;
         if (!isset($paramMappings[$key])) {
             throw QueryException::unknownParameter($key);
         }
         if (isset($rsm->metadataParameterMapping[$key]) && $value instanceof ClassMetadata) {
             $value = $value->getMetadataValue($rsm->metadataParameterMapping[$key]);
         }
         $value = $query->processParameterValue($value);
         $type = $parameter->getValue() === $value ? $parameter->getType() : Query\ParameterTypeInferer::inferType($value);
         foreach ($paramMappings[$key] as $position) {
             $types[$position] = $type;
         }
         $sqlPositions = $paramMappings[$key];
         // optimized multi value sql positions away for now,
         // they are not allowed in DQL anyways.
         $value = [$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::parameterTypeMismatch();
     }
     if ($sqlParams) {
         ksort($sqlParams);
         $sqlParams = array_values($sqlParams);
         ksort($types);
         $types = array_values($types);
     }
     return [$sqlParams, $types];
 }
开发者ID:startupz,项目名称:platform-1,代码行数:60,代码来源:NativeQueryExecutorHelper.php


注:本文中的Doctrine\ORM\Query::processParameterValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。