I have been using Cake now for over two years, and there have been a
few times, in different applications, I have had need of finding HABTM
relationships that do not exist, that is, to find an un-associated
model.  The SQL for such a query is rather simple;

SELECT * FROM near LEFT JOIN join ON (near.id = join.near_id) WHERE
join.far_id IS NULL;

That is, a standard CakePHP hasAndBelongsToMany association with one
difference, a LEFT join (and the condition of course, which requires
only that the join table column is set to "NOT NULL").  I doubt I am
the first that wishes to have alternate JOIN statements.

I wish to preserve the normal cake functions for $Model->find, etc,
and pagination.  This requires my 'list' to be setup in the model.  So
I have altered the core (I know, I know...) by adding in a similar
line to the type condition for hasOne assoc. and altered the "$merge[]
= $data" (~line:855 of dbo_source.php) to be outside the $uniqueIds if
statement (because in my particular case there are no "join table
ids").

I am wondering if there is anything I have missed?  Has anybody else
required to find a list of "remaining" items from a HABTM assoc, if so
how have you achieved this?

I would like to suggest this as an enhancement on trac, I am just
sifting the wheat.

-ghostpsalm

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to