I want to retrieve all records in parentTable that are not referenced in childTable.
i.e. I want all parent records that do not have any child records yet.
It works if I use the following "NOT IN" sql code in the parentTable's search() function:
$criteria->condition = 'parentID NOT IN (SELECT childTable.parentID_fk FROM childTable WHERE childTable.parentID_fk = :par1 )'; $criteria->params = array(':par1' => $this->parentID);
The problem is that the sql function (which gathers all the relevant child records) does not incorporate the child model's defaultScope() and thus retrieves the wrong child records (unless I repeat all the defaultScope() conditions in the above sql).
Is there any other - more Active Record - way of achieving the same result - without using sql?