I'm trying to setup a many-to-many relationship between "articles" and "keywords", but I keep getting the following error:
Fatal error: Uncaught exception 'Zend_Db_Table_Exception' with message 'No reference from table ArticlesKeywords to table Keywords' in......
Here is my code:
$articles = new Articles ( );
$rowset = $articles->find ( $id );
$rowset->current()->findManyToManyRowset('Keywords', 'ArticlesKeywords');
In Articles.php:
protected $_name = 'articles';
protected $_dependentTables = array('ArticlesKeywords');
In Keywords.php:
protected $_name = 'keywords';
protected $_dependentTables = array('ArticlesKeywords');
In ArticlesKeywords.php:
protected $_name = 'articles_keywords';
protected $_referenceMap = array (
'Keywords' => array (
'columns' => array ('keyword_id' ),
'refTableClass' => 'Keywords',
'refColumns' => array ('id' ) ),
'Articles' => array (
'columns' => array ('article_id' ),
'refTableClass' => 'Articles',
'refColumns' => array ('id' ) )
);
Here is a simplified ER Diagram of the database:
Articles:
id int(11) PK
....
Keywords:
id int(11) PK
....
ArticlesKeywords
id int(11) PK
article_id int(11) FK
keyword_id int(11) FK
Does anyone have any idea how else I can troubleshoot or is my syntax incorrect?
Thank you,
Henry
没有评论:
发表评论