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


PHP ORMException::invalidOrientation方法代码示例

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


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

示例1: _getOrderBySQL

 /**
  * Gets the ORDER BY SQL snippet for ordered collections.
  *
  * @param array $orderBy
  * @param string $baseTableAlias
  * @return string
  */
 protected final function _getOrderBySQL(array $orderBy, $baseTableAlias)
 {
     $orderBySql = '';
     foreach ($orderBy as $fieldName => $orientation) {
         if (!isset($this->_class->fieldMappings[$fieldName])) {
             throw ORMException::unrecognizedField($fieldName);
         }
         $orientation = strtoupper(trim($orientation));
         if ($orientation != 'ASC' && $orientation != 'DESC') {
             throw ORMException::invalidOrientation($this->_class->name, $fieldName);
         }
         $tableAlias = isset($this->_class->fieldMappings[$fieldName]['inherited']) ? $this->_getSQLTableAlias($this->_class->fieldMappings[$fieldName]['inherited']) : $baseTableAlias;
         $columnName = $this->_class->getQuotedColumnName($fieldName, $this->_platform);
         $orderBySql .= $orderBySql ? ', ' : ' ORDER BY ';
         $orderBySql .= $tableAlias . '.' . $columnName . ' ' . $orientation;
     }
     return $orderBySql;
 }
开发者ID:jfkz,项目名称:aquarel-cms,代码行数:25,代码来源:BasicEntityPersister.php

示例2: getOrderBySQL

    /**
     * Gets the ORDER BY SQL snippet for ordered collections.
     *
     * @param array  $orderBy
     * @param string $baseTableAlias
     *
     * @return string
     *
     * @throws \Doctrine\ORM\ORMException
     */
    protected final function getOrderBySQL(array $orderBy, $baseTableAlias)
    {
        $orderByList = array();

        foreach ($orderBy as $fieldName => $orientation) {

            $orientation = strtoupper(trim($orientation));

            if ($orientation != 'ASC' && $orientation != 'DESC') {
                throw ORMException::invalidOrientation($this->class->name, $fieldName);
            }

            if (isset($this->class->fieldMappings[$fieldName])) {
                $tableAlias = isset($this->class->fieldMappings[$fieldName]['inherited'])
                    ? $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]['inherited'])
                    : $baseTableAlias;

                $columnName    = $this->quoteStrategy->getColumnName($fieldName, $this->class, $this->platform);
                $orderByList[] = $tableAlias . '.' . $columnName . ' ' . $orientation;

                continue;
            }

            if (isset($this->class->associationMappings[$fieldName])) {

                if ( ! $this->class->associationMappings[$fieldName]['isOwningSide']) {
                    throw ORMException::invalidFindByInverseAssociation($this->class->name, $fieldName);
                }

                $tableAlias = isset($this->class->associationMappings[$fieldName]['inherited'])
                    ? $this->getSQLTableAlias($this->class->associationMappings[$fieldName]['inherited'])
                    : $baseTableAlias;

                foreach ($this->class->associationMappings[$fieldName]['joinColumns'] as $joinColumn) {
                    $columnName    = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform);
                    $orderByList[] = $tableAlias . '.' . $columnName . ' ' . $orientation;
                }

                continue;
            }

            throw ORMException::unrecognizedField($fieldName);
        }

        return ' ORDER BY ' . implode(', ', $orderByList);
    }
开发者ID:nattaphat,项目名称:hgis,代码行数:56,代码来源:BasicEntityPersister.php


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