lithium\data\model\Query::relationships()
Set and get the relationships.
Parameters
-
string
$relpath
A dotted path.
-
array
$config
the config array to set.
Returns
mixedThe relationships array or a relationship array if $relpath
is set. Returns
null
if a join doesn't exist.
Source
public function relationships($relpath = null, $config = null) {
if ($config) {
if (!$relpath) {
throw new InvalidArgumentException("The relation dotted path is empty.");
}
if (isset($config['model']) && isset($config['alias'])) {
$this->_models[$config['alias']] = $config['model'];
}
$this->_config['relationships'][$relpath] = $config;
return $this;
}
if (!$relpath) {
return $this->_config['relationships'];
}
if (isset($this->_config['relationships'][$relpath])) {
return $this->_config['relationships'][$relpath];
}
}