Thursday 15 September 2011

3rd level on the fly binding models in cakephp -



3rd level on the fly binding models in cakephp -

i'm trying bind 2 level of models mine (user hasmany comments, comments hasmany tags) on fly. tried won't work. found nil work here or via google.

$this->user->bindmodel(array( 'hasmany' => array( 'comment' => array( 'classname' => 'comment', 'hasmany' => array( 'tag' => array( 'classname' => 'tag' ) ) ) ) ));

any other ideas?

i'm using cakephp 2.5.1

$this->user->bindmodel(array( 'hasmany' => array( 'comment' => array( 'foreignkey' => false, 'conditions' => array('user.id = comment.user_id') ))));

and after this:

$this->user->comment->bindmodel(...)

but utilize containable behaviors, develop faster, , can bind tag comment model , juste utilize "contain" see : http://book.cakephp.org/2.0/fr/core-libraries/behaviors/containable.html

cakephp

No comments:

Post a Comment