Re: is this possible ? Seeking advice from mysql gurus :)
Thanks a lot !
Also I just wanted to post one other way to do this because I googled
and just found out.
before your query just post smth like this..
$this->Custommer->hasMany['Payment']['order'] = 'id DESC';
$this->Custommer->hasMany['Payment']['limit'] = 2;
you can also place conditions there.
Thanx Jeremy !
All the best !
Milos
On Feb 23, 4:27 pm, jeremyharris <funeralm...@gmail.com> wrote:
> You can do this in a single find() call, using containable. (It will still
> create many mysql queries because that's just the way it needs to be done,
> however it will filter all the data for you).
>
> Something like:
>
> $this-> Customer ->find('all', array(
> 'conditions' => array(
> 'Customer.id' => 1
> ),
> 'contain' => array(
> 'Invoice' => array(
> 'order' => 'Invoice.created DESC',
> 'limit' => 2
> ),
> 'Credit' => array(
> 'conditions' => array('Credit.active' => true)
> )
> )
> ));
>
> This should fetch the customer info and include that customer's last 2
> invoices and all active credits.
--
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home