relationships() public method

Set and get the relationships.
public relationships ( string $relpath = null, array $config = null ) : mixed
$relpath string A dotted path.
$config array the config array to set.
return mixed The relationships array or a relationship array if `$relpath` is set. Returns `null` if a join doesn't exist.
Example #1
0
 public function testRelationships()
 {
     $query = new Query(array('relationships' => array('Model1' => array('foo' => 'bar'))));
     $query->relationships('Model1.Model2', array('bar' => 'baz'));
     $expected = array('Model1' => array('foo' => 'bar'), 'Model1.Model2' => array('bar' => 'baz'));
     $relationships = $query->relationships();
     $this->assertEqual($expected, $relationships);
     $query = new Query();
     $query->relationships('Model1', array('foo' => 'bar'));
     $query->relationships('Model1.Model2', array('bar' => 'baz'));
     $relationships = $query->relationships();
     $this->assertEqual($expected, $relationships);
 }