Hi,

I am trying and failing to fetch a paginated result set using a
condition on a model which is two associations away.

Staff -> Person -> Organisation

I would have thought setting recursive to 1 or higher would have let
me achieve this but whilst the Staff model joins the Peron model fine,
I cannot get paginate (find) to then join the Organisation model so
the query fails as it can't find the Organisation.scheme_id field.

Pasting my StaffController and the Staff and Person models below.

class StaffController extends AppController {
  var $name = 'Staff';
  var $paginate = array(
    'limit' => '20',
    'order' => array(
      'Person.last_name' => 'ASC',
      'Person.first_name' => 'ASC'
    ),
    'recursive'=>'1'
  );

  function index($scheme_id = null) {
    ...
    $this->data['Staff'] = $this->paginate('Staff', array
('Organisation.scheme_id'=>$scheme_id));
  }
  ...
}

class Staff extends AppModel {
  var $name = 'Staff';
  var $useTable = 'staff';
  var $belongsTo = array(
    'Person',
    ...
  );
  ...
}

class Person extends AppModel {
  var $name = 'Person';
  var $belongsTo = array(
    ...
    'Organisation' => array(
      'counterCache' => true
    ),
    ...
  );
  ...
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to