lithium\data\model\Query::conditions PHP Method

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.
    public function conditions($conditions = null)
    {
        if (!$conditions) {
            return $this->_config['conditions'] ?: $this->_entityConditions();
        }
        $this->_config['conditions'] = array_merge((array) $this->_config['conditions'], (array) $conditions);
        return $this;
    }

Usage Example

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());
 }
All Usage Examples Of lithium\data\model\Query::conditions