我已经实现了参考指南中的留言簿示例,现在正尝试使用编辑功能对其进行扩展。
我已将此添加到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;
}
并更改了视图索引以提供编辑操作的链接:
<?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 ?>
映射器是标准的-直接从参考指南中复制和粘贴。
当我点击(http://quickstart/guestbook/edit/id/1)我遇到一个异常:[方法"getDbTable"不存在,并且没有被困在__call()中]
getDbTable()由同一文件中的find()函数调用。为什么它找不到getDbTable()?
我正在运行:PHP版本5.3.3-7+crushe1,Zend Engine v2.3.0,Apache/2.2.16(Debian)
您的类Application_Model_GuestbookMapper需要方法getDbTable()