Ratty, I put your function in the User Model, public function countPosts( $userId ){ $count = $this->Post->find('count', array( 'condition' => array('user_id' => $userId) ) ); return $count; }
and in my view I try to call it like this : <?php $userId = $this->Session->read('Auth.User.id'); echo User::countPosts($userId); ?> but it returns Undefined property: View::$Post [*CORE/Cake/View/View.php*, line *806*] *Fatal error*: Call to a member function find() on a non-object in * /app/Model/User.php* on line *64* * * Surely some stupid mistake I'm making ? * * Le mardi 19 juin 2012 00:21:25 UTC+2, JonStark a écrit : > > Let's say USer hasMany Post. > > If i debug my user it will produce an array like : > > User > > -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php