本文整理汇总了PHP中BasePeer::turnSelectColumnsToAliases方法的典型用法代码示例。如果您正苦于以下问题:PHP BasePeer::turnSelectColumnsToAliases方法的具体用法?PHP BasePeer::turnSelectColumnsToAliases怎么用?PHP BasePeer::turnSelectColumnsToAliases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasePeer
的用法示例。
在下文中一共展示了BasePeer::turnSelectColumnsToAliases方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCountStatement
protected function getCountStatement($con = null)
{
$dbMap = Propel::getDatabaseMap($this->getDbName());
$db = Propel::getDB($this->getDbName());
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
$needsComplexCount = $this->getGroupByColumns() || $this->getOffset() || $this->getLimit() || $this->getHaving() || in_array(Criteria::DISTINCT, $this->getSelectModifiers());
$con->beginTransaction();
try {
$this->basePreSelect($con);
$params = array();
if ($needsComplexCount) {
if (BasePeer::needsSelectAliases($this)) {
if ($this->getHaving()) {
throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part');
}
BasePeer::turnSelectColumnsToAliases($this);
}
$selectSql = BasePeer::createSelectSql($this, $params);
$sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt';
} else {
// Replace SELECT columns with COUNT(*)
$this->clearSelectColumns()->addSelectColumn('COUNT(*)');
$sql = BasePeer::createSelectSql($this, $params);
}
$stmt = $con->prepare($sql);
BasePeer::populateStmtValues($stmt, $params, $dbMap, $db);
$stmt->execute();
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
return $stmt;
}
示例2: testTurnSelectColumnsToAliasesDuplicate
public function testTurnSelectColumnsToAliasesDuplicate()
{
$c1 = new Criteria();
$c1->addSelectColumn(BookPeer::ID);
$c1->addSelectColumn(BookPeer::ID);
BasePeer::turnSelectColumnsToAliases($c1);
$c2 = new Criteria();
$c2->addAsColumn('book_ID', BookPeer::ID);
$c2->addAsColumn('book_ID_1', BookPeer::ID);
$this->assertTrue($c1->equals($c2));
}