1
我目前从一本名为学习Zend框架“Appress临Zend框架技术,构建一个完整的CMS项目”和我被困在这里提交错误后,该页面是假设点重定向到confirm
行动,但这种重定向依赖于模型,从而节省的bug到数据库抛出的结果。Zend框架:lastInsertId将返回0
这里是
public function createBug($name, $email, $date, $url, $description, $priority, $status) {
// create a new rows in the bugs table
$row = $this->createRow();
// set the row data
$row->author = $name;
$row->email = $email;
$dateObject = new Zend_Date($date);
$row->date = $dateObject -> get(Zend_Date::TIMESTAMP);
$row->url = $url;
$row->description = $description;
$row->priority = $priority;
$row->status = $status;
//Save the new row
$row->save();
// now fetch the id of the row you just created and return it
$id = $this->_db->lastInsertId();
return $id;
}
这些记录保存在数据库中,但是$ ID总是返回0,这是造成重定向进行转义模型错误的代码。
如果将'$ id'设置为'$ row-> id'而不是'lastInsertId()'会发生什么? – 2010-06-20 06:30:46
@Mike B,这个工作你为什么不上传此作为一个答案? – Starx 2010-06-20 06:39:13
这表明从今天上午的问题。但正如你所提到的,我已经替换了代码并且解决了。谢谢。 – 2014-06-13 06:22:16