Friday, April 27, 2012

Paginate - conditions of linked model

Hi,
I have a model called User and a model called Connection. The User has
a hasMany relation with Connection. When I use $this->paginate() I get
all Users 100 with all there Connections. Nothing strange... I get all
the users with there connections.

But.. I want to filter de Connections. So I still want all 100 users
but only show there connections with, lets say, status = 1. In CakePHP
1.3 it was something like this:

$this->User->hasMany['Connection']['conditions'] =
array('Connection.status' => 1);
$this->data = $this->User->find('all');

I'm using CakePHP 2.1 now and I want the same result with paginator.

Can someone help me to setup the controller?

Thanks, Tim.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: