Sunday, February 27, 2011

Probelm with hasMany relationship and find/paginate

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?

The problem might be that I can have a member who has right now no
payment, as I am going to charge him the first time, but I need to
find this member in any case.

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

Thanks!

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