Insert data to MySQL database from Zend 1.12.3 in NetBeans 7.4

In last post You display on website all records from country table.
Today we add new row to country table and display data.
First You may double click on IndexController.php file.
c90Let’s add new country with France name from Europe continent.
So in indexAction method write after creating object Application_Model_DbTable_Country this code:

$data=array('name'=>'France','continent'=>'Europe');
try{
$Country->insert($data);
} catch( Zend_Db_Statement_Exception $e)
{ echo 'Error message(insert data to table country):'.$e.getMessage();}

Inserting data into table must be in try – catch block. You may also display message when the error appear inserting data.

Save this file.
c91Run Your country application.
c92

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.