I have some trouble finding a solution for this..
Error: Call to a member function schema() on a non-object
File: /Cake/Model/Model.php
Line: 3627
In my Database there are the tables articles,hashtags and the association articles_hashtags with the foreignkeys article_id and hashtag_id .. So i am trying to get the information what hashtags each article has..
My Article Model
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 your help!!
Additionally: If i put the generated sql select query from the debugger sql log into my sql database i get the right results .. so i guess theres something wrong with the controller?!