I am have created a web app that will use PHP to insert a row into an Oracle database. I am using Zend Framework to connect to the database. When I test it I dont get any errors but I dont see that added row in the table.
Here is my code:
$remote = $_SERVER['REMOTE_ADDR'];
// Connect with PDO
$db = Zend_Db::factory('PDO_OCI',
array(
'dbname' => $dbname,
'username' => $dbuser,
'password' => $dbpass
)
);
$req = "INSERT INTO " . $dbtable . " (id, url, adddate, addip) VALUES ('', '" . $safeurl . "', SYSDATE, '" . $remote . "')";
$res = $db->prepare($req);
$res->execute();
$safeurl is generated by user input, and it is sanitized.
id is autogenerated when you insert the row.
Please help me solve this. Thanks!
You have to commit. Each update/insert/delete begins a new transaction if it’s not started. So issue another
COMMITstatement after inserting a record (or a bunch of records). Oracle doesn’t have autocommit mode.