Thursday, February 23, 2012

is this possible ? Seeking advice from mysql gurus :)

Hi :)

so far I haven't had any really complex querys so there is one now and
I seek for the advice on how to handle it. Now I now how to fix this
redneck style (several queries etc, or one big and then filter in
controller), however I am looking for a little more elegant solution.

I have a model which has about 7 other sub models (has many) . Main is
a customer and has many appointments, invoices , payments etc...
So I need to fetch a customer and 2 last inserted of each of its has
many models. Example is : One specific customer (found by ID) and 2 of
his last invoices, 2 of his last payments and so on..
And to make it a bit more complicated, for just one of these sub
models (named Credits) I need to fetch all of the active ones...

My way so far is to fetch all of the data with classic find and then
in one FOR loop filter out data I do not need... Is there a way a
single query could do this.. ??

Thank you in advance you mighty mysql gurus :)

All the best,
Milos

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: