【发布时间】:2010-03-17 10:50:41
【问题描述】:
我有一个用于将一些数据保存到数据库的操作类。在操作类中,我通过 url 获取 id。我必须将 id 保存在表中。
我通过 $request->getParameter('id') 获取 id
我用这个代码保存
$this->form->bind($request->getParameter('question_answers'));
if ($this->form->isValid())
{
$this->form->save();
$this->redirect('@homepage');
}
在模型类中我使用了覆盖保存方法来保存额外的字段
公共函数保存(Doctrine_Connection $conn = null) { if ($this->isNew()) {
$now=date('Y-m-d H:i:s', time());
$this->setPostedAt($now);
} 返回父级::save($conn); 所以我想在这里获取 id 值。 那么如何将 id 值从动作类传递给模型类
是在动作类本身中保存 id 的任何其他方式 提前致谢
【问题讨论】:
-
那个 id 是关于什么的?它是数据库表中对象的 id 吗?
-
不,是从 url 获取的数字
标签: symfony1