I have some problems finding a solution for this.
Error: Call to a member function schema() on a non-object File: /Cake/Model/Model.php Line: 3627
My database has article tables, hashtags, and the association of articles_hashtags with foreignkeys article_id and hashtag_id .. Therefore, I try to get the information that each article hashtags has.
Model of my article
class Article extends AppModel { public $hasAndBelongsToMany = array( 'Hashtag' => array( 'className' => 'Hashtag', 'joinTable' => 'articles_hashtags', 'foreignKey' => 'article_id', 'associationForeignKey' => 'hashtag_id', 'unique' => true, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', 'with' => '' ) ); }
Article controller
class ArticleController extends AppController { var $name = 'Article'; public $helpers = array("Html", "Form"); public function index() { $this->set("posts", $this->Article->find("all")); } }
Thanks for the help!
Optional: If I put the generated sql select query from the sql debugger log into my sql database, I get the correct results. So I think something is wrong with the controller ?!
php cakephp many-to-many has-and-belongs-to-many model-associations
tobysas
source share