php - CakePHP 3.0 - order by assocation count? -
lets have table users hasone userdata , hasmany contests.
how retrieve users pagination ordered by: 1: first ones have more 1 contest , userdata filled 2: second ones have userdata filled , no contests 3: last ones empty userdata , contests
im paginating far cant solve problem:
$this->paginate = [ 'contain' => [ 'userdatas', 'contests' ], 'maxlimit' => 20, ]; $query = $this->users->find('all'); $this->set('users', $this->paginate($query));
Comments
Post a Comment