Hi together, I have problems to create a count query with recursive conditions... To clear up things, I ll try to make an example:
We have 4 tables: ModelA, ModelB, ModelC, ModelD They are connected like this: - ModelA contains a FK to ModelB. - ModelB contains a FK to ModelC. - ModelC contains a FK to ModelD. And I want to make a distinct count of the PK of ModelB, combined with some conditions spreaded over the tables. This would look like the following SQL: SELECT COUNT (DISTINCT ModelA.modelb_id) FROM ModelA INNER JOIN ModelB ON ModelB.id = ModelA.modelb_id INNER JOIN ModelC ON ModelC.id = ModelB.modelc_id INNER JOIN ModelD ON ModelD.id = ModelC.modeld_id WHERE ModelD.something = 'somevalue' AND ModelA.someother = 'thatvalue' AND ModelB.somethird = 'thosevalues'; So, how can I translate that into Cake syntax? ;-) How would I need to link the models together and how do I need to form the count? I've tried a lot of things in quiet a lot of hours and googled around for days but was not able to find a working solution. So this is my last hope.. *crossing fingers* Thanks in advance! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
