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


PHP QueryException::invalidLockMode方法代码示例

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


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

示例1: walkSelectStatement

 /**
  * {@inheritdoc}
  */
 public function walkSelectStatement(AST\SelectStatement $AST)
 {
     $sql = $this->walkSelectClause($AST->selectClause);
     $sql .= $this->walkFromClause($AST->fromClause);
     $sql .= $this->walkWhereClause($AST->whereClause);
     $sql .= $AST->groupByClause ? $this->walkGroupByClause($AST->groupByClause) : '';
     $sql .= $AST->havingClause ? $this->walkHavingClause($AST->havingClause) : '';
     if (($orderByClause = $AST->orderByClause) !== null) {
         $sql .= $AST->orderByClause ? $this->walkOrderByClause($AST->orderByClause) : '';
     } else {
         if (($orderBySql = $this->_generateOrderedCollectionOrderByItems()) !== '') {
             $sql .= ' ORDER BY ' . $orderBySql;
         }
     }
     $sql = $this->platform->modifyLimitQuery($sql, $this->query->getMaxResults(), $this->query->getFirstResult());
     if (($lockMode = $this->query->getHint(Query::HINT_LOCK_MODE)) !== false) {
         switch ($lockMode) {
             case LockMode::PESSIMISTIC_READ:
                 $sql .= ' ' . $this->platform->getReadLockSQL();
                 break;
             case LockMode::PESSIMISTIC_WRITE:
                 $sql .= ' ' . $this->platform->getWriteLockSQL();
                 break;
             case LockMode::OPTIMISTIC:
                 foreach ($this->selectedClasses as $selectedClass) {
                     if (!$selectedClass['class']->isVersioned) {
                         throw \Doctrine\ORM\OptimisticLockException::lockFailed($selectedClass['class']->name);
                     }
                 }
                 break;
             case LockMode::NONE:
                 break;
             default:
                 throw \Doctrine\ORM\Query\QueryException::invalidLockMode();
         }
     }
     return $sql;
 }
开发者ID:nemekzg,项目名称:doctrine2,代码行数:41,代码来源:SqlWalker.php

示例2: walkSelectStatement

 /**
  * {@inheritdoc}
  */
 public function walkSelectStatement(AST\SelectStatement $AST)
 {
     $limit = $this->query->getMaxResults();
     $offset = $this->query->getFirstResult();
     $lockMode = $this->query->getHint(Query::HINT_LOCK_MODE);
     $sql = $this->walkSelectClause($AST->selectClause) . $this->walkFromClause($AST->fromClause) . $this->walkWhereClause($AST->whereClause);
     if ($AST->groupByClause) {
         $sql .= $this->walkGroupByClause($AST->groupByClause);
     }
     if ($AST->havingClause) {
         $sql .= $this->walkHavingClause($AST->havingClause);
     }
     if ($AST->orderByClause) {
         $sql .= $this->walkOrderByClause($AST->orderByClause);
     }
     if (!$AST->orderByClause && ($orderBySql = $this->_generateOrderedCollectionOrderByItems())) {
         $sql .= ' ORDER BY ' . $orderBySql;
     }
     if ($limit !== null || $offset !== null) {
         $sql = $this->platform->modifyLimitQuery($sql, $limit, $offset);
     }
     if ($lockMode === null || $lockMode === false || $lockMode === LockMode::NONE) {
         return $sql;
     }
     if ($lockMode === LockMode::PESSIMISTIC_READ) {
         return $sql . ' ' . $this->platform->getReadLockSQL();
     }
     if ($lockMode === LockMode::PESSIMISTIC_WRITE) {
         return $sql . ' ' . $this->platform->getWriteLockSQL();
     }
     if ($lockMode !== LockMode::OPTIMISTIC) {
         throw QueryException::invalidLockMode();
     }
     foreach ($this->selectedClasses as $selectedClass) {
         if (!$selectedClass['class']->isVersioned) {
             throw OptimisticLockException::lockFailed($selectedClass['class']->name);
         }
     }
     return $sql;
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:43,代码来源:SqlWalker.php


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