Yep thanks,

I hadn't realized that you could use parts of other models in a find
for a specific model.

In the end my query looked like this:

$requests = $this->paginate('Request', array(
                'Request.user_id' =>
                $this->Auth->user('id'),
                'Loan.id' => null));


Much nicer now and paginate is accurate with no messing around.

On Jun 20, 7:33 am, schneimi <[email protected]> wrote:
> Hi Adam,
>
> you just need a condition. I am not sure if this is the most elegant
> way, but here is an example:
>
> $this->Request->find('all', array('loan_id !=' => 0));
>
> Regards,
> Michael
>
> Adam Sunderland schrieb:
>
> > Currently I have two tables connected by a hasOne relationship.
>
> > More clearly, a request has one loan. And of course, a loan belongs to
> > a request.
>
> > What I want to do is find all of the requests where a loan does not
> > exist and also vice versa.
>
> > Is there a nice way to do this using a model find method?
>
> > Currently, I find all of the requests then go through and remove all
> > of the requests that either have or do not have a loan according to
> > the situation. But this does not seem like the most elegant solution,
> > and might be a bottleneck when the application increases in size.
>
> > Thanks for the help,
>
> > Adam
--~--~---------~--~----~------------~-------~--~----~
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