The answer was found by using the principles explained at

http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/

In summary to get the pagination I was after I applied the
following ...
  // unbind Client model for entire request
  $this->Referral->unbindModel(array('belongsTo' =>array('Client')),
false);
  // unbind Client->Person model for entire request
  $this->Referral->Client->unbindModel(array('belongsTo' =>array
('Person')), false);
  // rebind Client and Person models with custom condition for Person
model forcing join
  $this->Referral->bindModel(
    array(
      'belongsTo' => array(
        'Client'=>array(),
        'Person'=>array('foreignKey'=>false, 'conditions'=>array
('Client.person_id = Person.id'))
      )
    ),
    false
  );
  // run paginate with conditions
  $this->data['Referrals'] = $this->paginate('Referral', array(
    'Person.is_deleted' => '0',
    'Referral.is_deleted' => '0',
    'Referral.scheme_id' => $scheme_id
  ));

This has the benefit of running only one query and allows results to
be ordered by fields in the Referral, Client or Person model

Thanks teknoid!
--~--~---------~--~----~------------~-------~--~----~
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