Zend Framework: Method "getDbTable" does not exist and was not trapped in __call()
I've implemented the guestbook example from the reference guide, and am now trying to extend it with edit functionality.
I've added this to the GuestbookController:
public function editAction()
{
$model = new Application_Model_Guestbook();
$request = $this->getRequest();
if ($request->isPost()) {
Print_r('posted');die();
}
$model = Application_Model_GuestbookMapper::find($this->getRequest()->getParam('id'), $model);
$form = new Application_Form_Guestbook(array('model' => $model));
$this->view->form = $form;
}
And have altered the view index to provide a link to the edit action:
<?php foreach ($this->entries as $entry): ?>
<?php $url = $this->url(
array(
'controller' => 'guestbook',
'action' => 'edit',
'id'=>$entry->id
),
'default',
true)
?>
<dt><?php echo $this->escape($entry->email) ?></dt>
<dd><a href="<?php echo $url; ?>"><?php echo $this->escape($entry->comment) ?></a></dd>
<?php endforeach ?>
The mapper is standard - straight copy and paste from the reference guide.
When I click thr开发者_如何学运维ough (http://quickstart/guestbook/edit/id/1) I am confronted with an exception: [Method "getDbTable" does not exist and was not trapped in __call() ]
getDbTable() is called by the find() function which is in the same file. Why then can it not find getDbTable()?
I'm running: PHP Version 5.3.3-7+squeeze1, Zend Engine v2.3.0, Apache/2.2.16 (Debian)
your class Application_Model_GuestbookMapper needs method getDbTable()
精彩评论