Of course, it's the syntax again..
$myScroll->User->unbindModel('hasMany',array('Photo'));
Should read
$myScroll->User->unbindModel(array('hasMany'=>array('Photo')));
_____
From: [email protected] [mailto:[email protected]] On Behalf
Of Alan Asher
Sent: Thursday, December 10, 2009 7:34 PM
To: [email protected]
Subject: unbindModel cranium scratcher
Here's the code I used to hack my way through this.
$myScroll=new Scroll($scroll_id);
$myScroll->User->bindModel(
array('hasMany' => array(
'Photo' => array(
'className' => 'Photo',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '1=0', //hack to make the results
limited since unbind model doesn't work
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
)
)
);
$myScroll->Behaviors->attach('Containable');
$myScroll->User->unbindModel('hasMany',array('Photo'));
$data = $myScroll->find('all',array('recursive'=>2,
'contain'=>array('User','User.Photo'),
'conditions'=>array('Scroll.id'=>$scroll_id),'limit'=>20));
pr($data);
$this->controller->set('userScroll',$data);
The models are: User has many scrolls and scroll has and belongs to many
users , users belong to photos and has many photos
Earlier this week I figured out how to use the unbindModel to get rid of the
hasMany from my user model and it worked perfectly.
But now I'm instantiating my own model and it seems to be behaving
differently.
I expect this
$myScroll->User->unbindModel('hasMany',array('Photo')); to work but it
doesn't do a flippin thing. So I hacked it by modifying the user's has many
photos model to never return a result.
Does anyone know what I'm doing wrong?
Alan
Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en