當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Criteria::combine方法代碼示例

本文整理匯總了PHP中Propel\Runtime\ActiveQuery\Criteria::combine方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criteria::combine方法的具體用法?PHP Criteria::combine怎麽用?PHP Criteria::combine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel\Runtime\ActiveQuery\Criteria的用法示例。


在下文中一共展示了Criteria::combine方法的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);
 }
開發者ID:naldz,項目名稱:cyberden,代碼行數:31,代碼來源:CriteriaCombineTest.php

示例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);
 }
開發者ID:disider,項目名稱:Propel2,代碼行數:16,代碼來源:CriteriaCombineTest.php


注:本文中的Propel\Runtime\ActiveQuery\Criteria::combine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。