Tuesday, September 6, 2011

Re: order by for hasMany


<?php

class User extends AppModel {
    var $name = 'User';                
    var $hasMany = array(
        'Comment' => array(
            'className'     => 'Comment',
            'foreignKey'    => 'user_id',
            'conditions'    => array('Comment.status' => '1'),
            'order'    => 'Comment.created DESC',
            'limit'        => '5',
            'dependent'=> true
        )
    );  
}
?>

Does that help?

Tarique

On Wed, Sep 7, 2011 at 12:14 PM, Miqdad Ali <mr.miqdad.ali@gmail.com> wrote:
i have a post and comments table post have hasmany comments ..  i am taking post order_by post.post_date desc , i want to get all comments also with orderby comments.post_date desc

how can i get this please reply .....






---------------------------------------------------------


Miqdad Ali K
+919995258790
http://www.miqdadalik.com


--
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



--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
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: