joins() public method

Set and get the joins
public joins ( string $name = null, object | string $join = null ) : mixed
$name string Optional name of join. Unless two parameters are passed, this parameter is regonized as `$join`.
$join object | string A single query object or an array of query objects
return mixed The joins array or a join array if `$name` is set. Returns `null` if a join doesn't exist.
Example #1
0
 public function testJoins()
 {
     $query = new Query(array('joins' => array(array('foo' => 'bar'))));
     $query->joins(array('bar' => 'baz'));
     $expected = array(array('foo' => 'bar'), array('bar' => 'baz'));
     $joins = $query->joins();
     $this->assertEqual($expected, $joins);
     $this->assertEqual('bar', $joins[0]['foo']);
     $this->assertFalse(isset($joins[0]['bar']));
     $this->assertEqual('baz', $joins[1]['bar']);
     $this->assertFalse(isset($joins[1]['foo']));
     $query->joins('zim', array('dib' => 'gir'));
     $joins = $query->joins();
     $this->assertEqual(3, count($joins));
     $this->assertEqual('gir', $joins['zim']['dib']);
     $expected = array(array('foo' => 'bar'), array('bar' => 'baz'), 'zim' => array('dib' => 'gir'));
     $this->assertEqual($expected, $joins);
 }