Exemplo n.º 1
0
 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(array('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(array('cond3', 'cond4'), 'aNd', 'cond34');
     $this->c->combine(array('cond12', 'cond34'), 'oR');
     $expect = "SELECT  FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))";
     $expect_params = array(array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'));
     $params = array();
     $result = BasePeer::createSelectSql($this->c, $params);
     $this->assertEquals($expect, $result);
     $this->assertEquals($expect_params, $params);
 }