Hi, I'm trying to set up a dynamic association in my controller without using a foreignKey, and Cake keeps putting a foreignKey clause in the SQL join no matter what I do.
Essentially, in certain cases I want to limit the results of my query by joining a table to my main search table and adding a WHERE clause, but the join happens on a column that is not exactly a foreignKey column like Cake expects. The SQL is actually quite simple, just: SELECT a_bunch_of_fields FROM master_table AS MasterTable LEFT JOIN related_table AS RelatedTable ON (MasterTable.system_id = RelatedTable.system_id) WHERE RelatedTable.user_id = $user_id So basically it's a two-column primary key on the related_table (user_id and system_id), where I'm using the system_id to join and the user_id to filter. system_id is a column shared by both the MasterTable and the RelatedTable, but it is not a primary key for either (in fact it is part of a 3-column unique key on MasterTable). Seems to me in Cake I should be able to accomplish this by simply setting the foreignKey element of the belongsTo association to false, and supplying a condition for the system_id. The latter part works, but Cake still insists on adding a MasterTable.related_table_id clause in the Join statement. I really want to get this working through Cake's nice findAll() model method because I've already done a LOT of work getting a really complex filtering UI to work nicely with it, and I'd hate to have to re-implement the thing myself just so I can add this join. Anybody? Help? How can I do an association without Cake adding a foreignKey? Thanks, Matthew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---