Share on Google+Share on Google+

ZF Data Update in DB


Editing a book and its content is identical to the adding. With the help of given coding we can edit the necessary changes. After every entry there is a link called edit which proceeds us to another page which is made for editing any record...

Edit Record in Zend Framework:

Now if someone wants to change, update or edit any record then the required settings and coding are given below, as usual the coding is different from conventional PHP coding, so go through the coding carefully and make necessary changes. Code of the section below is pretty similar with the adding section.



public function editAction()


$this->view->title = "Edit Book";


$form = new Application_Form_Book();


$this->view->form = $form;

if ($this->getRequest()->isPost()) {

$formData = $this->getRequest()->getPost();

if ($form->isValid($formData)) {

$id = (int)$form->getValue('id');

$author = $form->getValue('author');

$publisher = $form->getValue('publisher');

$title = $form->getValue('title');

$books = new Application_Model_DbTable_Books();

$books->updateBook($id, $author,$publisher,$title);


} else {



} else {

$id = $this->_getParam('id', 0);

if ($id > 0) {

$books = new Application_Model_DbTable_Books();







<?php echo $this->form;?>



edit book

Now make necessary changes and click the save button, it will update the book table.



Posted on: May 7, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null