本文整理汇总了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()));
}
示例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;
}
示例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;
}
示例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;
}
示例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()));
}
示例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;
}
示例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));
}