Hi guys,
i am trying to create references between my model classes based on
Zend_Db_Table_Abstract but it does not function. I donĀ“t know why and so
I hope
someone of you guys can help me :-)
_I have 2 simple tables:_
flabben.article (id, [...], author_id)
flabben.author (id, [...])
*File:* _~/application/models/Article.php
_*<?php*
*class* Article *extends* Flabben_Db_Table
{
*protected* $_name = 'article';
*protected* $_schema = 'flabben';
*protected* $_primary = 'id';
*protected* $_referenceMap = *array*(
'Author' => *array*(
'columns' => 'author_id',
'refTableClass' => 'Author',
'refColumns' => 'id'
)
);
}
*?>*
*File:* _~/application/models/Author.php_
*<?php*
*class* Author *extends* Flabben_Db_Table
{
*protected* $_name = 'author';
*protected* $_schema = 'flabben';
*protected* $_primary = 'id';
*protected* $_dependentTables = *array*('Article');
}
*?>
*Now I am trying to get the depending author for the actual selected article
(in my application, this code is inside IndexController::indexAction).
*<?php*
$articleTable = *new* Article;
$articles = $articleTable->find(1);
$article = $articles->current();
$article->findDependentRowset('Author');
*?>
*But the result is an Exception :(
*Zend_Db_Table_Exception*
[0] No reference from table Author to table Article
#0
C:\Server\httpd\htdocs\Flabben\library\Zend\Db\Table\Row\Abstract.php(680):
Zend_Db_Table_Abstract->getReference('Article', NULL)
#1
C:\Server\httpd\htdocs\Flabben\library\Zend\Db\Table\Row\Abstract.php(723):
Zend_Db_Table_Row_Abstract->_prepareReference(Object(Author),
Object(Article), NULL)
#2 C:\Server\httpd\htdocs\Flabben\library\Flabben\Db\Table\Row.php(48):
Zend_Db_Table_Row_Abstract->findDependentRowset(Object(Author), NULL)
#3
C:\Server\httpd\htdocs\Flabben\application\views\scripts\index\index.phtml(23):
Flabben_Db_Table_Row->findDependentRowset('Author')
#4 C:\Server\httpd\htdocs\Flabben\library\Zend\View.php(46):
include('C:\Server\httpd...')
#5 C:\Server\httpd\htdocs\Flabben\library\Zend\View\Abstract.php(765):
Zend_View->_run('C:\Server\httpd...')
#6
C:\Server\httpd\htdocs\Flabben\library\Zend\Controller\Action\Helper\ViewRenderer.php(860):
Zend_View_Abstract->render('index/index.pht...')
#7
C:\Server\httpd\htdocs\Flabben\library\Zend\Controller\Action\Helper\ViewRenderer.php(881):
Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...',
NULL)
#8
C:\Server\httpd\htdocs\Flabben\library\Zend\Controller\Action\Helper\ViewRenderer.php(929):
Zend_Controller_Action_Helper_ViewRenderer->render()
#9
C:\Server\httpd\htdocs\Flabben\library\Zend\Controller\Action\HelperBroker.php(161):
Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#10
C:\Server\httpd\htdocs\Flabben\library\Zend\Controller\Action.php(506):
Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#11
C:\Server\httpd\htdocs\Flabben\library\Zend\Controller\Dispatcher\Standard.php(242):
Zend_Controller_Action->dispatch('indexAction')
#12
C:\Server\httpd\htdocs\Flabben\library\Zend\Controller\Front.php(927):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#13 C:\Server\httpd\htdocs\Flabben\www\index.php(22):
Zend_Controller_Front->dispatch()
#14 {main}
-- Jan