I have been there too but that does not help me much. Actually I have model1 that hasMany model2 and model2 belongsTo model1. What I want to do is a way to query Model1 records by checking model2 conditions. For example suppose in model2 you have a field containing the user id that created this model2 record. I want to find model1 records in 2 ways :
1) that do not have any model2 record for the current user (meaning that record model2.user != current_user) but model2 records can exists for other users 2) that have at least a model2 record for the current user (ie : model2.user = current user) again other model2 record can be associated to model1, but for different user This can be seen as an Auction business, model1 would be the objects in the auction and model 2 the offers the users makes for this object. For a particular user you want to show him the object he hasn't put any offer, opposite you want to show him all the objects he put a price on .... (do not know if this is clearer..) Actually I stuck to do this, because in a hasMany relation, there is not JOIN so if I set some condition to model2, I get "unknow table Model2". In another hand I have tried the reverse, meaning seaching by model 2 (since it has a LEFT JOIN to model1) and I can make conditions, that can work partially by then I have a problem when 2 records model2 exist referering to the same record model1, the model1 record appear then twice ... Not simple, and actually basically I want to make a query that would "count" in the condition the number of records of model2 matching the current user... well, if you have any idea, even using a simple SQL statement ..would be great Thanks Franck --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
