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


PHP QueryException::semanticalError方法代码示例

本文整理汇总了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);
 }
开发者ID:pscheit,项目名称:psc-cms,代码行数:10,代码来源:EntityRepositoryDeliverQueryTest.php

示例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 . ')';
 }
开发者ID:guiwoda,项目名称:DoctrineExtensions,代码行数:13,代码来源:DateSub.php

示例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.');
     }
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:14,代码来源:DateAddFunction.php

示例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.');
         }
     }
 }
开发者ID:krishcdbry,项目名称:z-zangura,代码行数:13,代码来源:DateAddFunction.php

示例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()));
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:29,代码来源:Parser.php

示例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);
    }
开发者ID:rswharton,项目名称:Symfony2-Test,代码行数:31,代码来源:Parser.php


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