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