Monday, February 28, 2011

Re: Probelm with hasMany relationship and find/paginate


Hi
On Sun, Feb 27, 2011 at 3:20 PM, heohni <heidi.anselstetter@consultingteam.de> wrote:
Hi,

I may have a basic missunderstanding of cakephp, but I do the
following:

I have a Member Model with some belongsTo and 1 hasMany relations.
A 'member' hasMany 'payments'.
A 'payment' belongsTo a 'member'

Now I need to create a new page where I want to show a summary of all
members with are filtered by status which I get out of the 'payments'
table.

Therefore I created a new model with no use of a database and a own
controller.
The reason for these files is, that after I show the list of members,
I have to do some other functions which I wanted to have seperate form
the members controller.

In my controller, I added
var $uses = array('Member', 'Payment');
function index(){
$this->set('results', $this->paginate());
}

This performs 3 statements:
1. count statements for the paginator functions
2. Member with all belongsTo
3. Payments

The results are OK and correct, I just need to filter out all
Payment.status != 6.
How can I do this?

I think this link will be useful

http://bakery.cakephp.org/articles/shird10/2010/08/29/pagination-for-custom-queries

$cond = array('Payment.status <>' => 1 ) ;

$this->set('results', $this->paginate('Parent', $cond));

I am not sure with which i gave . Please refrer link which I gave


I am really stuck at this point :-( and need help please!!
Regards

sathia
http://www.sathia27.wordpress.com

--
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: