php - As in Kohana 3.3 sort the list of users, the number of orders? -


suppose have 2 orm model:

class model_user extends orm {     protected $_has_many = array(         'orders' => array(             'model' => 'order',             'foreign_key' => 'order_id',             ),         ); }  class model_order extends orm {     protected $_belongs_to = array(         'author' => array(             'model' => 'user',             'foreign_key' => 'author_id',             ),         ); }  orm::factory('user')->find_all(); //displays list of users 

as can see list of users, sorted number of orders? possible?

you can sort records using order_by

orm::factory('user')->order_by('order_id', 'desc')->find_all(); //displays list of users 

Comments

Popular posts from this blog

java - Incorrect order of records in M-M relationship in hibernate -

command line - Use qwinsta in PowerShell ISE -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -