本文整理汇总了PHP中Doctrine\ORM\Query\QueryException::semanticalError方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryException::semanticalError方法的具体用法?PHP QueryException::semanticalError怎么用?PHP QueryException::semanticalError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query\QueryException
的用法示例。
在下文中一共展示了QueryException::semanticalError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testwithException_throwsPscDoctrineQueryException
/**
* @expectedException Psc\Doctrine\QueryException
*/
public function testwithException_throwsPscDoctrineQueryException()
{
$query = $this->doublesManager->createQueryMock(array('getResult', 'getScalarResult', 'getDQL'), $this->emm);
$query->expects($this->once())->method('getDQL')->will($this->returnValue('SELECT * FROM DAM\\AGE'));
$query->expects($this->once())->method('getResult')->will($this->throwException(\Doctrine\ORM\Query\QueryException::semanticalError('DAM\\AGE ist keine Tabelle natürlich')));
$this->runDeliverQuery(NULL, 'result', $query);
}
示例2: getSql
/**
* @param \Doctrine\ORM\Query\SqlWalker $sqlWalker
* @return string
* @throws QueryException
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
$unit = strtoupper(is_string($this->unit) ? $this->unit : $this->unit->value);
if (!in_array($unit, self::$allowedUnits)) {
throw QueryException::semanticalError('DATE_SUB() does not support unit "' . $unit . '".');
}
return 'DATE_SUB(' . $this->firstDateExpression->dispatch($sqlWalker) . ', INTERVAL ' . $this->intervalExpression->dispatch($sqlWalker) . ' ' . $unit . ')';
}
示例3: getSql
/**
* @override
*/
public function getSql(SqlWalker $sqlWalker)
{
switch (strtolower($this->unit->value)) {
case 'day':
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker));
case 'month':
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker));
default:
throw QueryException::semanticalError('DATE_ADD() only supports units of type day and month.');
}
}
示例4: getSql
public function getSql(SqlWalker $sqlWalker)
{
$unit = strtolower($this->unit);
if ($unit == "day") {
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker));
} else {
if ($unit == "month") {
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker));
} else {
throw QueryException::semanticalError('DATE_ADD() only supports units of type day and month.');
}
}
}
示例5: 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()));
}
示例6: 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);
}