本文整理汇总了PHP中Propel\Runtime\ActiveQuery\Criteria::addCond方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addCond方法的具体用法?PHP Criteria::addCond怎么用?PHP Criteria::addCond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\ActiveQuery\Criteria
的用法示例。
在下文中一共展示了Criteria::addCond方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testClonedCriteriaNotAffected2
public function testClonedCriteriaNotAffected2()
{
$this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL);
$this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL);
$this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_AND, 'cond12');
$this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL);
$this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL);
$this->c->combine(['cond3', 'cond4'], Criteria::LOGICAL_AND, 'cond34');
$clonedCriteria = clone $this->c;
$expect1 = $this->getSql("SELECT FROM ");
$params1 = [];
$result1 = $this->c->createSelectSql($params1);
$this->assertEquals($expect1, $result1);
$this->c->addCond('cond5', "INVOICE.COST5", "5000", Criteria::GREATER_EQUAL);
$this->c->combine(['cond34', 'cond5'], Criteria::LOGICAL_AND);
$expect2 = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST3>=:p1 AND INVOICE.COST4<=:p2) AND INVOICE.COST5>=:p3)");
$expect_params2 = [['table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'], ['table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'], ['table' => 'INVOICE', 'column' => 'COST5', 'value' => '5000']];
$params2 = [];
$result2 = $this->c->createSelectSql($params2);
$this->assertEquals($expect2, $result2);
$this->assertEquals($expect_params2, $params2);
// Cloned criteria should not be affected by the combine of cond34 above
// we should still be able to use it in the clone for another combine
$clonedCriteria->combine(['cond12', 'cond34'], Criteria::LOGICAL_OR);
$expect3 = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))");
$expect_params3 = [['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], ['table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'], ['table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000']];
$params3 = [];
$result3 = $clonedCriteria->createSelectSql($params3);
$this->assertEquals($expect3, $result3);
$this->assertEquals($expect_params3, $params3);
}
示例2: testCombineDirtyOperators
public function testCombineDirtyOperators()
{
$this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL);
$this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL);
$this->c->combine(['cond1', 'cond2'], 'AnD', 'cond12');
$this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL);
$this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL);
$this->c->combine(['cond3', 'cond4'], 'aNd', 'cond34');
$this->c->combine(['cond12', 'cond34'], 'oR');
$expect = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))");
$expect_params = [['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], ['table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'], ['table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000']];
$params = [];
$result = $this->c->createSelectSql($params);
$this->assertEquals($expect, $result);
$this->assertEquals($expect_params, $params);
}