Hi there I have three models that are chained with belongsTo in one direction and hasMany in the other direction: Model1 belongsTo Model2 belongsTo Model3 and Model3 hasMany Model2 hasMany Model1
Now I need to query model1 and also get the related data from model2 and model3 which can be easily achieved by settings model1->recursive = 2 and then use model1->findall. The resulting SQL ( I use postgres but mysql should be similar): Cake makes a join on the model1 and model2, keeps the resulting ids of the entries in model2, then makes a query for each of these ids on model2 and a query for the related model3. This causes two problems: a) I cannot restrict the result depending on some columns on model3 as the first query fails with 'missing from-clause entry for table model3'. b) The query is really inefficient: Example: If the first query returns 10 results we need 21 queries for in total (the join query and then 10 queries each for model2 and model3). We could get the same result by having only one query which uses a left join for joining model1 and model2 and another left join for joining model2 and model3. I have found a trac issue regarding this but it was closed as wontfix: https://trac.cakephp.org/ticket/2931 Any tips on how to solve this? I use Cake 1.2.0.5427alpha. Claudia --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
