conditions() public method

When getting current conditions and none are configured for the query, will ask the bound entity for its conditions instead.
public conditions ( string | array | null $conditions = null ) : string | Query
$conditions string | array | null Condition/s to append to existing conditions. Provide `null` to get current conditions.
return string | Query Either the currrent conditions when $conditions is `null` or the query itself when setting the conditions.
Example #1
0
 public function testExtra()
 {
     $object = new MockPostObject(array('id' => 1, 'data' => 'test'));
     $query = new Query(array('conditions' => 'foo', 'extra' => 'value', 'extraObject' => $object));
     $this->assertEqual(array('foo'), $query->conditions());
     $this->assertEqual('value', $query->extra());
     $this->assertEqual($object, $query->extraObject());
     $this->assertNull($query->extra2());
 }
Example #2
0
 public function testFluentInterface()
 {
     $query = new Query();
     $conditions = array('foo' => 'bar');
     $fields = array('foo', 'bar', 'baz', 'created');
     $order = array('created' => 'ASC');
     $result = $query->conditions($conditions)->fields($fields)->order($order);
     $this->assertEqual($result, $query);
     $this->assertEqual($conditions, $query->conditions());
     $this->assertEqual($fields, $query->fields());
     $this->assertEqual($order, $query->order());
 }