Hi all, im using zend framework and I am trying to create a test method for inserting data into my database but have been stuck for days!!!, cant seem to figure out whats wrong.😕. when i call the method in my browser I am getting a blank screen and no action on the database end. CAN ANYONE SPOT THE PROBLEM?🙁. Ive got the following code in my controller
public function testInsertAction()
{
try{
//Create a DB object
require_once "Db/Db_Db.php";
$db = Db_Db::conn();
$statement = "INSERT INTO accounts(username, email, password,status, created_date)
VALUES('test_1', 'test@test.com', 'password','active', NOW())";
$db->query($statement);
//Close Connection
$db->closeConnection();
echo "Completed Inserting";
}
catch(Zend_Db_Exception $e)
{
echo $e->getMessage();
}
//Supress the View
$this->_helper->viewRenderer->setNoRender();
}
And...i have the following code in my models/Db/Db_Db.php directory....
<?php
/**
* Database handler.
*
*/
class Db_Db
{
public static function conn(){
$db = new Zend_Db_Adapter_Pdo_Mysql(array("host" => "localhost",
"port" => "<Your Port Number>",
"username" => "user",
"password" => "mypass",
"dbname" => "mypass");
return $db;
}
}