本文整理匯總了PHP中Doctrine\ORM\Query::getDql方法的典型用法代碼示例。如果您正苦於以下問題:PHP Query::getDql方法的具體用法?PHP Query::getDql怎麽用?PHP Query::getDql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\Query
的用法示例。
在下文中一共展示了Query::getDql方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
// Building informative message
$message = 'line 0, col ' . (isset($token['position']) && $token['position'] > 0 ? $token['position'] : '-1') . " near '" . substr($dql, $token['position'], $length) . "': Error: " . $message;
throw \Doctrine\ORM\Query\QueryException::semanticalError($message);
}
示例2: __construct
/**
* Creates a new query parser object.
*
* @param Query $query The Query to parse.
*/
public function __construct(Query $query)
{
$this->_query = $query;
$this->_em = $query->getEntityManager();
$this->_lexer = new Lexer($query->getDql());
$this->_parserResult = new ParserResult();
//$this->_parserResult->setEntityManager($this->_em);
}
示例3: semanticalError
/**
* Generates a new semantical error.
*
* @param string $message Optional message.
* @param array|null $token Optional token.
*
* @return void
*
* @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()));
}
示例4: getQueryCacheKey
/**
* @param Query $query
*
* @return string
*/
public function getQueryCacheKey(Query $query)
{
$hints = $query->getHints();
ksort($hints);
return md5($query->getDql() . var_export($query->getParameters(), true) . var_export($hints, true) . '&firstResult=' . $query->getFirstResult() . '&maxResult=' . $query->getMaxResults() . '&hydrationMode=' . $query->getHydrationMode());
}