Re: [fw-general] Zend_Db_Table: Problem with Relatationships

2008-03-06 Thread Jan Pieper

Yeah, this works fine :-)

-- Jan



Jan Pieper wrote:

$article->findDependentRowset('Author');

But the result is an Exception :(

Zend_Db_Table_Exception: No reference from table Author to table Article



In you example, a foreign key in Article references a primary key in Author.

So Author is the "parent", Article is the "dependent".  You are querying the
reverse relationship, which does not exist in this example.

Use this:

  $article->findParentRow('Author');

Regards,
Bill Karwin




Re: [fw-general] Zend_Db_Table: Problem with Relatationships

2008-03-06 Thread Bill Karwin


Jan Pieper wrote:
> 
> $article->findDependentRowset('Author');
> 
> But the result is an Exception :(
> 
> Zend_Db_Table_Exception: No reference from table Author to table Article
> 

In you example, a foreign key in Article references a primary key in Author.

So Author is the "parent", Article is the "dependent".  You are querying the
reverse relationship, which does not exist in this example.

Use this:

  $article->findParentRow('Author');

Regards,
Bill Karwin
-- 
View this message in context: 
http://www.nabble.com/Zend_Db_Table%3A-Problem-with-Relatationships-tp15882889s16154p15883753.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend_Db_Table: Problem with Relatationships

2008-03-06 Thread Jan Pieper

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

_* *array*(
'columns' => 'author_id',
'refTableClass' => 'Author',
'refColumns' => 'id'
)
);
}


*?>*

*File:* _~/application/models/Author.php_
*

*Now I am trying to get the depending author for the actual selected article
(in my application, this code is inside IndexController::indexAction).

*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