本文整理汇总了PHP中Propel\Runtime\ActiveQuery\Criteria::addHaving方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addHaving方法的具体用法?PHP Criteria::addHaving怎么用?PHP Criteria::addHaving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\ActiveQuery\Criteria
的用法示例。
在下文中一共展示了Criteria::addHaving方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHavingRaw
public function testHavingRaw()
{
$c = new Criteria();
$c->addSelectColumn(BookTableMap::TITLE);
$c->addAsColumn("isb_n", BookTableMap::ISBN);
$c->addHaving('isb_n = ?', '1234567890123', \PDO::PARAM_STR);
$expected = 'SELECT book.TITLE, book.ISBN AS isb_n FROM book HAVING isb_n = :p1';
$params = array();
$result = $c->createSelectSql($params);
$this->assertEquals($expected, $result);
$c->doSelect($this->con);
$expected = 'SELECT book.TITLE, book.ISBN AS isb_n FROM book HAVING isb_n = \'1234567890123\'';
$this->assertEquals($expected, $this->con->getLastExecutedQuery());
}
示例2: testMergeWithHavingConditions
public function testMergeWithHavingConditions()
{
$c1 = new Criteria();
$cton = $c1->getNewCriterion(BookTableMap::COL_TITLE, 'foo', Criteria::EQUAL);
$c1->addHaving($cton);
$c2 = new Criteria();
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing having condition');
$c1 = new Criteria();
$c2 = new Criteria();
$cton = $c2->getNewCriterion(BookTableMap::COL_TITLE, 'foo', Criteria::EQUAL);
$c2->addHaving($cton);
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges having condition to an empty having');
$c1 = new Criteria();
$cton = $c1->getNewCriterion(BookTableMap::COL_TITLE, 'foo', Criteria::EQUAL);
$c1->addHaving($cton);
$c2 = new Criteria();
$cton = $c2->getNewCriterion(BookTableMap::COL_TITLE, 'bar', Criteria::EQUAL);
$c2->addHaving($cton);
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING (book.TITLE=:p1 AND book.TITLE=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() combines having with AND');
}