本文整理匯總了PHP中Propel\Runtime\ActiveQuery\Criteria::needsSelectAliases方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criteria::needsSelectAliases方法的具體用法?PHP Criteria::needsSelectAliases怎麽用?PHP Criteria::needsSelectAliases使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Propel\Runtime\ActiveQuery\Criteria
的用法示例。
在下文中一共展示了Criteria::needsSelectAliases方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testNeedsSelectAliases
public function testNeedsSelectAliases()
{
$c = new Criteria();
$this->assertFalse($c->needsSelectAliases(), 'Empty Criterias don\'t need aliases');
$c = new Criteria();
$c->addSelectColumn(BookTableMap::COL_ID);
$c->addSelectColumn(BookTableMap::COL_TITLE);
$this->assertFalse($c->needsSelectAliases(), 'Criterias with distinct column names don\'t need aliases');
$c = new Criteria();
BookTableMap::addSelectColumns($c);
$this->assertFalse($c->needsSelectAliases(), 'Criterias with only the columns of a model don\'t need aliases');
$c = new Criteria();
$c->addSelectColumn(BookTableMap::COL_ID);
$c->addSelectColumn(AuthorTableMap::COL_ID);
$this->assertTrue($c->needsSelectAliases(), 'Criterias with common column names do need aliases');
}
示例2: applyLimit
/**
* @see AdapterInterface::applyLimit()
*
* @param string $sql
* @param integer $offset
* @param integer $limit
* @param null|Criteria $criteria
*/
public function applyLimit(&$sql, $offset, $limit, $criteria = null)
{
$params = array();
if ($criteria && $criteria->needsSelectAliases()) {
$crit = clone $criteria;
$selectSql = $this->createSelectSqlPart($crit, $params, true);
$sql = $selectSql . substr($sql, strpos($sql, 'FROM') - 1);
}
$sql = 'SELECT B.* FROM (' . 'SELECT A.*, rownum AS PROPEL_ROWNUM FROM (' . $sql . ') A ' . ') B WHERE ';
if ($offset > 0) {
$sql .= ' B.PROPEL_ROWNUM > ' . $offset;
if ($limit > 0) {
$sql .= ' AND B.PROPEL_ROWNUM <= ' . ($offset + $limit);
}
} else {
$sql .= ' B.PROPEL_ROWNUM <= ' . $limit;
}
}