On Tue, Mar 15, 2011 at 3:32 AM, heohni
<[email protected]> wrote:
> Hi,
>
> I tried this:
>
> $this->paginate = array(
>            'conditions' => array(
>                'Agentprovision.agent_id' => $id
>            ),
>            'fields' => array(
>                'Agentprovision.id', 'Agentprovision.apr_status',
> 'Agentprovision.apr_summe', 'Payment.created'
>            ),
>            'contain' => array(
>                'Payment.id',
>                'Member.id'
>            )
>        );
>
> But I get this message:
> Model "Agentprovision" is not associated with model "Member"
>
> Which is correct. But I don't understand, because I get the Payments,
> and from the Payments I have the member_id reference to the Members
> table.
> So somehow I should get able to get the member data anyhow?

In the first fields array, include only those fields which belong to
the main model. That appears to be Agentprovision here, although I'm
not sure. Is this in AgentsController?

In the contain array, include the model names as keys to arrays that
have the field names. Like so:

'contain' => array(
        'Model1' => array(
                'fields' => array(
                        'Model1.id'
                ),
                'Model2' => array(
                        'fields' => array(
                                'Model2.id'
                        ),
                        'Model3' => array(
                                'fields' => array(
                                        'Model3.id',
                                        ...
                                )
                        )
                )
        )
)

Start with models directly associated with the model you're
paginating, then indent for the next level, and so on.

Be sure to include ALL primary and foreign keys at a minimum. I've
found that leaving out an FK can lead to hours of frustrating
debugging. Stupidly, this has bit on more than one occasion.

Next, your associations look bad to me:

Member belongsTo Agent
Member hasMany Payment

**Payment belongsTo Agentprovision**
Payment belongsTo Member

Agent hasMany Agentprovision
Agent hasMany Member

Agentprovision belongsTo Agent
**Agentprovision belongsTo Payment**

Without knowinng more about the purpose of some of these models,
though, I can't suggest any fix.

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to