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


PHP Query::getDQL方法代码示例

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


在下文中一共展示了Query::getDQL方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setIndexBy

 /**
  * Return users indexed by id
  *
  * @param Query  $query
  * @param string $fieldName
  *
  * @return \Doctrine\ORM\AbstractQuery
  */
 public function setIndexBy(Query $query, $fieldName)
 {
     if (!strpos($query->getDQL(), 'WHERE')) {
         return $query->setDQL($query->getDQL() . ' INDEX BY ' . $fieldName);
     }
     return $query->setDQL(str_replace('WHERE', 'INDEX BY ' . $fieldName . ' WHERE', $query->getDQL()));
 }
开发者ID:apfz,项目名称:ACLInterfaceBundle,代码行数:15,代码来源:IndexByTrait.php

示例2: getQuery

 /**
  * @param \Kdyby\Persistence\Queryable $repository
  *
  * @throws UnexpectedValueException
  * @return \Doctrine\ORM\Query
  */
 protected function getQuery(Queryable $repository)
 {
     $query = $this->toQuery($this->doCreateQuery($repository));
     if ($this->lastQuery && $this->lastQuery->getDQL() === $query->getDQL()) {
         $query = $this->lastQuery;
     }
     if ($this->lastQuery !== $query) {
         $this->lastResult = new ResultSet($query, $this, $repository);
     }
     return $this->lastQuery = $query;
 }
开发者ID:kdyby,项目名称:doctrine,代码行数:17,代码来源:QueryObject.php

示例3: applySorting

 /**
  * @param string|array $columns
  * @throws InvalidStateException
  * @return ResultSet
  */
 public function applySorting($columns)
 {
     $this->updating();
     $sorting = [];
     foreach (is_array($columns) ? $columns : func_get_args() as $name => $column) {
         if (!is_numeric($name)) {
             $column = $name . ' ' . $column;
         }
         if (!preg_match('~\\s+(DESC|ASC)\\s*\\z~i', $column = trim($column))) {
             $column .= ' ASC';
         }
         $sorting[] = $column;
     }
     if ($sorting) {
         $dql = Strings::normalize($this->query->getDQL());
         if (!preg_match('~^(.+)\\s+(ORDER BY\\s+((?!FROM|WHERE|ORDER\\s+BY|GROUP\\sBY|JOIN).)*)\\z~si', $dql, $m)) {
             $dql .= ' ORDER BY ';
         } else {
             $dql .= ', ';
         }
         $this->query->setDQL($dql . implode(', ', $sorting));
     }
     $this->iterator = NULL;
     return $this;
 }
开发者ID:kdyby,项目名称:doctrine,代码行数:30,代码来源:ResultSet.php

示例4: updateQuery

 /**
  * Updates the configured query object with the where-clause and query-hints.
  *
  * @param string $prependQuery Prepends this string to the where-clause
  *                             (" WHERE " or " AND " for example)
  *
  * @return self
  */
 public function updateQuery($prependQuery = ' WHERE ')
 {
     $whereCase = $this->getWhereClause($prependQuery);
     if ('' !== $whereCase) {
         $this->query->setDQL($this->query->getDQL() . $whereCase);
         $this->query->setHint($this->getQueryHintName(), $this->getQueryHintValue());
     }
     return $this;
 }
开发者ID:rollerworks,项目名称:search-doctrine-orm,代码行数:17,代码来源:WhereBuilder.php

示例5: semanticalError

 /**
  * Generates a new semantical error.
  *
  * @param string $message Optional message.
  * @param array $token Optional token.
  *
  * @throws \Doctrine\ORM\Query\QueryException
  */
 public function semanticalError($message = '', $token = null)
 {
     if ($token === null) {
         $token = $this->_lexer->lookahead;
     }
     // Minimum exposed chars ahead of token
     $distance = 12;
     // Find a position of a final word to display in error string
     $dql = $this->_query->getDql();
     $length = strlen($dql);
     $pos = $token['position'] + $distance;
     $pos = strpos($dql, ' ', $length > $pos ? $pos : $length);
     $length = $pos !== false ? $pos - $token['position'] : $distance;
     $tokenPos = isset($token['position']) && $token['position'] > 0 ? $token['position'] : '-1';
     $tokenStr = substr($dql, $token['position'], $length);
     // Building informative message
     $message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message;
     throw QueryException::semanticalError($message, QueryException::dqlError($this->_query->getDQL()));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:27,代码来源:Parser.php

示例6: getCachedResult

 /**
  *
  * @param Query $query        	
  * @param string $cacheItemKey        	
  * @return array|bool|mixed|string
  */
 protected function getCachedResult(Query $query, $cacheItemKey = '', $ttl = 0)
 {
     if (!$cacheItemKey) {
         $cacheItemKey = ($this->cache_prefix ? $this->cache_prefix : get_called_class()) . md5($query->getDQL());
     }
     $cache = $this->getEntityManager()->getConfiguration()->getResultCacheImpl();
     // test if item exists in the cache
     if ($cache->contains($cacheItemKey)) {
         // retrieve item from cache
         $items = $cache->fetch($cacheItemKey);
     } else {
         // retrieve item from repository
         $items = $query->getResult();
         // save item to cache
         $cache->save($cacheItemKey, $items, $ttl);
     }
     return $items;
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:24,代码来源:Paginator.php

示例7: info

 /**
  * (non-PHPdoc) @see \Mathielen\ImportEngine\Storage\StorageInterface::info().
  */
 public function info()
 {
     $count = count($this->reader());
     return new StorageInfo(array('name' => $this->query->getDQL(), 'type' => 'DQL Query', 'count' => $count));
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:8,代码来源:DoctrineStorage.php


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