Controller :
<?php
class AdminController extends Zend_Controller_Action
{
public function init()
{
error_reporting(E_ALL);
}
public function indexAction()
{
// blank //
}
public function registerAction()
{
// database configuration //
$config = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'zendfirst'
);
$db = new Zend_Db_Adapter_Pdo_Mysql($config);
// get request(get/post) //
$request = $this->getRequest();
if($request->isPost('fsubmit')) {
$insert_data = array(
'first_name' => $request->first_name,
'last_name' => $request->last_name
);
$db->insert('admin', $insert_data);
}
}
}
View :
<form method="post" action="">
<div class="form_div">
<label for="first_name">First Name</label>
<input type="text" value="" name="first_name" id="first_name" />
</div>
<div class="form_div">
<label for="last_name">Last Name</label>
<input type="text" value="" name="last_name" id="last_name" />
</div>
<div class="form_div">
<input type="submit" value="Register" name="fsubmit" id="fsubmit" />
</div>
</form>
<style>
.form_div {
padding : 5px;
}
</style>
Settings “php.ini”
extension=php_pdo_mysql.dll
Database table :
admin_id first_name last_name
-------- ---------- ---------
throwing the error
An error occurred
Application error
What is the problem? Is there any “profiler” like CodeIgniter in Zend Framework?
You are treating the post values as an object. Try this: