當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Query::getParameters方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Query::getParameters方法的典型用法代碼示例。如果您正苦於以下問題:PHP Query::getParameters方法的具體用法?PHP Query::getParameters怎麽用?PHP Query::getParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Query的用法示例。


在下文中一共展示了Query::getParameters方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSlice

 /**
  * {@inheritdoc}
  */
 public function getSlice($offset, $length)
 {
     $query = clone $this->query;
     $query->setParameters($this->query->getParameters());
     $query->setFirstResult($offset)->setMaxResults($length);
     return $query->getQuery()->getResult();
 }
開發者ID:olegstepura,項目名稱:doctrine-multicolumn-search,代碼行數:10,代碼來源:PagerfantaAdapter.php

示例2: take

 /**
  * @param int $offset
  * @return \Porpaginas\Page
  */
 public function take($offset, $limit)
 {
     if ($this->result !== null) {
         return new ArrayPage(array_slice($this->result, $offset, $limit), $offset, $limit, count($this->result));
     }
     $query = clone $this->query;
     $query->setParameters($this->query->getParameters());
     foreach ($this->query->getHints() as $name => $value) {
         $query->setHint($name, $value);
     }
     $query->setFirstResult($offset)->setMaxResults($limit);
     return new ORMQueryPage(new Paginator($query, $this->fetchCollection));
 }
開發者ID:stof,項目名稱:porpaginas,代碼行數:17,代碼來源:ORMQueryResult.php

示例3: 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

示例4: 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

示例5: cloneQuery

 /**
  * @param  Query $query
  * @return Query
  */
 protected static function cloneQuery(Query $query)
 {
     /* @var $countQuery Query */
     $countQuery = clone $query;
     $params = $query->getParameters();
     $countQuery->setParameters($params);
     return $countQuery;
 }
開發者ID:php-pike,項目名稱:pike,代碼行數:12,代碼來源:Paginate.php

示例6: cloneQuery

 /**
  * @param Query $query
  * @return Query
  */
 protected static function cloneQuery(Query $query)
 {
     /* @var $countQuery Query */
     $countQuery = clone $query;
     $params = $query->getParameters();
     foreach ($params as $key => $param) {
         $countQuery->setParameter($key, $param);
     }
     return $countQuery;
 }
開發者ID:Clansuite,項目名稱:Clansuite,代碼行數:14,代碼來源:Paginate.php

示例7: cloneQuery

 /**
  * Clones a query.
  *
  * @param Query $query The query.
  *
  * @return Query The cloned query.
  */
 private function cloneQuery(Query $query)
 {
     /* @var $cloneQuery Query */
     $cloneQuery = clone $query;
     $cloneQuery->setParameters(clone $query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $cloneQuery->setHint($name, $value);
     }
     return $cloneQuery;
 }
開發者ID:jirinapravnik,項目名稱:common,代碼行數:17,代碼來源:PaginatorWithoutDistinct.php

示例8: cloneQuery

 /**
  * Clone specified query with parameters.
  *
  * @param Query $query
  *
  * @return Query
  */
 protected function cloneQuery(Query $query)
 {
     $aclAppliedQuery = clone $query;
     $params = $query->getParameters();
     /* @var $param Parameter */
     foreach ($params as $param) {
         $aclAppliedQuery->setParameter($param->getName(), $param->getValue(), $param->getType());
     }
     return $aclAppliedQuery;
 }
開發者ID:axelvnk,項目名稱:KunstmaanBundlesCMS,代碼行數:17,代碼來源:AclHelper.php

示例9: cloneQuery

 /**
  * Clones the given $query and copies all used
  * parameters and hints
  *
  * @param Query $query
  * @return Query
  */
 public static function cloneQuery(Query $query)
 {
     $clonedQuery = clone $query;
     $clonedQuery->setParameters($query->getParameters());
     // attach hints
     foreach ($query->getHints() as $name => $hint) {
         $clonedQuery->setHint($name, $hint);
     }
     return $clonedQuery;
 }
開發者ID:Dren-x,項目名稱:mobit,代碼行數:17,代碼來源:Helper.php

示例10: __construct

 /**
  * @param \Doctrine\ORM\Query $query          The Doctrine Query
  * @param array               $fields         Fields to export
  * @param string              $dateTimeFormat
  */
 public function __construct(Query $query, array $fields, $dateTimeFormat = 'r')
 {
     $this->query = clone $query;
     $this->query->setParameters($query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $this->query->setHint($name, $value);
     }
     $this->propertyAccessor = PropertyAccess::createPropertyAccessor();
     $this->propertyPaths = array();
     foreach ($fields as $name => $field) {
         if (is_string($name) && is_string($field)) {
             $this->propertyPaths[$name] = new PropertyPath($field);
         } else {
             $this->propertyPaths[$field] = new PropertyPath($field);
         }
     }
     $this->dateTimeFormat = $dateTimeFormat;
 }
開發者ID:LamaDelRay,項目名稱:test_symf,代碼行數:23,代碼來源:DoctrineORMQuerySourceIterator.php

示例11: createWhereInQuery

 /**
  * @param Query $query
  * @param array $ids
  * @param string $namespace
  * @return Query
  */
 public static function createWhereInQuery(Query $query, array $ids, $namespace = 'pgid')
 {
     // don't do this for an empty id array
     if (count($ids) > 0) {
         $whereInQuery = clone $query;
         $whereInQuery->setParameters($query->getParameters());
         $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('DoctrineExtensions\\Paginate\\WhereInWalker'));
         $whereInQuery->setHint('id.count', count($ids));
         $whereInQuery->setHint('pg.ns', $namespace);
         $whereInQuery->setFirstResult(null)->setMaxResults(null);
         foreach ($ids as $i => $id) {
             $i = $i + 1;
             $whereInQuery->setParameter("{$namespace}_{$i}", $id);
         }
         return $whereInQuery;
     } else {
         return $query;
     }
 }
開發者ID:noikiy,項目名稱:inovi,代碼行數:25,代碼來源:Paginate.php

示例12: __construct

 /**
  * @param \Doctrine\ORM\Query $query          The Doctrine Query
  * @param array               $fields         Fields to export
  * @param string              $dateTimeFormat
  */
 public function __construct(Query $query, array $fields, $dateTimeFormat = 'r')
 {
     $this->query = clone $query;
     $this->query->setParameters($query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $this->query->setHint($name, $value);
     }
     // Note : will be deprecated in Symfony 3.0, conserved for 2.2 compatibility
     // Use createPropertyAccessor() for 3.0
     // @see Symfony\Component\PropertyAccess\PropertyAccess
     $this->propertyAccessor = PropertyAccess::getPropertyAccessor();
     $this->propertyPaths = array();
     foreach ($fields as $name => $field) {
         if (is_string($name) && is_string($field)) {
             $this->propertyPaths[$name] = new PropertyPath($field);
         } else {
             $this->propertyPaths[$field] = new PropertyPath($field);
         }
     }
     $this->dateTimeFormat = $dateTimeFormat;
 }
開發者ID:serialken,項目名稱:BugTracker,代碼行數:26,代碼來源:DoctrineORMQuerySourceIterator.php

示例13: cloneQuery

 /**
  * Clones a query.
  *
  * @param Query $query The query.
  *
  * @return Query The cloned query.
  */
 private function cloneQuery(Query $query)
 {
     /* @var $cloneQuery Query */
     $cloneQuery = clone $query;
     $cloneQuery->setParameters($query->getParameters());
     return $cloneQuery;
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:14,代碼來源:DoctrineORMAdapter.php

示例14: getHash

 protected function getHash(Query $query) : string
 {
     $sql = $query->getSQL();
     $params = $query->getParameters();
     return sha1($sql . serialize($params));
 }
開發者ID:wellcommerce,項目名稱:dataset,代碼行數:6,代碼來源:DataSetCacheManager.php

示例15: cloneQuery

 /**
  * Makes full clone of the given query, including its parameters and hints
  *
  * @param Query $query
  * @return Query
  */
 protected function cloneQuery(Query $query)
 {
     $result = clone $query;
     // clone parameters
     $result->setParameters(clone $query->getParameters());
     // clone hints
     foreach ($query->getHints() as $name => $value) {
         $result->setHint($name, $value);
     }
     return $result;
 }
開發者ID:snorchel,項目名稱:platform,代碼行數:17,代碼來源:BufferedQueryResultIterator.php


注:本文中的Doctrine\ORM\Query::getParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。