Sunday, March 6, 2011

Need help with bindModel

Hi,

An Agent has many Agentprovisions
A Agentprovision hasOne Payment
A Payment belongsTo a Member

I am now in my Agent Model / Controller.
I would like now to get a results set, where I get
- all Agentprovisions
-- with its Payment
-- its Member

the first 2 I get already with
$this->Agent->Agentprovision->recursive = 1;
$this->Agent->Agentprovision->unBindModel(array('belongsTo' =>
array('Agent')), false); (this is only cosmetic to keep the statement
smaller)
$this->paginate($this->Agent->Agentprovision,
array('Agentprovision.agent_id'=>$id));

This give me that result:
Array
(
[0] => Array
(
[Agentprovision] => Array
(
[id] => 162
[agent_id] => 1
[payment_id] => 1216
)

[Payment] => Array
(
[id] => 1216
[member_id] => 5
)

)

My questions now, how can I bind the Member Model?
I tried
$this->Agent->Agentprovision->Payment->bindModel(array('belongsTo' =>
array('Member' => array('foreignKey' => 'member_id'))), false);
But this is not changing anything.

Any ideas what's wrong?

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