Reputation: 418
It's not clear to me how I can fetch records that don't have a reference in an other row using contain()
in Cakephp
public function initialize(array $config)
{
$this->hasmany('Prior', [
'className' => 'Prior',
'foreignKey' => 'photoID'
]);
}
public function search()
{
$query = $this->find('all')->contain(['Prior']);
return $query;
}
This returns something like:
-> results
->0
->ID = 1
->Prior = null
->1
->ID = 2
->Prior = array()
->2
->ID = 3
->Prior = array()
->3
->ID = 4
->Prior = null
How can I return only the NULL
results?
Upvotes: 0
Views: 641