本文整理汇总了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;
}
示例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);
}