I have a model named Application
. And Application
is associated to has_many
model named Location
.
Application
has many Location
In my Application query:
$this->Application->find('all', array('conditions' => 'Application.status' => 'accepted'));
I'm finding applications
where status
is accepted
.
Next thing that I would like to achieve is to find Application
records where associated Location
is empty/null or in other words where count
of Location
records is 0.
I tried to make join
query like this:
$join_query = array(
'table' => 'locations',
'alias' => 'Location',
'type' => 'INNER',
'conditions' => array(
'Location.application_id = Application.id',
'OR' => array(
array('Location.id' => NULL)
)
)
);
But seems like it's just querying Application
records that do have associated Location
records.
Thanks in advanced if you guys have any idea(s).