php - CakePHP display HABTM associations -


i'm new cakephp , want display list of associated tags in post's view.

i have searched on web , nothing seems work.

this have @ moment:

// postcontroller public function view($id = null) {     $this->set('tags', $this->post->tag->find('all', array('conditions' => array('posttag.post_id' => $id))));      if (!$id) {         throw new notfoundexception(__('invalid post'));     }      $post = $this->post->findbyid($id);     if (!$post) {         throw new notfoundexception(__('invalid post'));     }     $this->set('post', $post); }  // post's view.ctp echo $this->text->tolist($tags); 

this error i'm getting:

error: sqlstate[42s22]: column not found: 1054 unknown column 'posttag.post_id' in 'where clause' 

this should easy stuck.

thanks can help!

is tag model loaded in post controller? how simply:

$this->set('tags', $this->tag->find('all', array('conditions' => array('tag.post_id' => $id))));


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -