Currently trying to setup a many to many relationship without success. Tried
googling it but havent found anything, so im turning to you!
I'm using a modular structure which looks like this:
-application
-modules
-admin
-views
-models
-DbTable
-forms
-...
in the models directory i have DAOs and in the DbTable directory the
Zend_Db_Table classes (pretty basic).
I have 3 table classes:
class Admin_Model_DbTable_News extends Zend_Db_Table_Abstract
{
protected $_name = 'news';
protected $_primary = 'id_news';
protected $_sequence = true;
protected $_dependentTables = array('Admin_Model_DbTable_ListChroniques');
}
class Admin_Model_DbTable_Chronique extends Zend_Db_Table_Abstract
{
protected $_name = 'chronique';
protected $_primary = 'id_chronique';
protected $_sequence = true;
protected $_dependentTables = array('Admin_Model_DbTable_ListChroniques');
}
class Admin_Model_DbTable_ListChroniques extends Zend_Db_Table_Abstract{
protected $_name = 'listchroniques';
protected $_primary = array('id_chronique_fk', 'id_news_fk');
protected $_referenceMap = array(
'Chronique' => array(
'columns' => array('id_chronique_fk'),
'refTableClass' => 'Admin_Model_DbTable_Chronique',
'refColumns' => array('id_chronique')
),
'News' => array(
'columns' => array('id_news_fk'),
'refTableClass' => 'Admin_Model_DbTable_News',
'refColumns' => array('id_news')
)
);
}
In my DAO class I do this:
class Admin_Model_NewsDao{
public function getListChroniques($newsId){
$table= new Admin_Model_DbTable_News;
$news= $table->find($newsId);
$news= $news->current();
$chroniquesRowset=
$news->findManyToManyRowset('Admin_Model_DbTable_Chronique','Admin_Model_DbTable_ListChroniques');
return $chroniqueRowset;
}
}
When i try to use the getListChroniques($newsId) method, i get:
Zend_Db_Table_Exception: No reference from table Admin_Model_DbTable_Editeur
to table Admin_Model_DbTable_Chronique
Any help would be appreciated! Hope my question isnt too stupid :drunk:
Cheers
--
View this message in context: http://www.nabble.com/-ZF-1.8.1--findManyToManyRowset-tp23763243p23763243.html
Sent from the Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论