1
현재 "Appress Pro Zend Framework 기법, 전체 CMS 프로젝트 빌드"라는 책에서 Zend Framework를 배우고 있으며 버그를 제출 한 후 페이지가 있다고 가정합니다. 이 작업은 confirm
작업으로 리디렉션되지만이 리디렉션은 모델에 의해 throw 된 결과에 따라 달라 지므로 버그가 데이터베이스에 저장됩니다. 여기 Zend Framework : 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'를'lastInsertId()'대신'$ row-> id'로 설정하면 어떻게됩니까? –
@Mike B, 이것은 왜 당신이 대답으로 이것을 업로드하지 않았는가? – Starx
오늘 아침부터 문제가 있습니다. 그러나 언급 한대로 코드를 대체하고 해결되었습니다. 고맙습니다. –