I am calling INSERT and DELETE Statements via PHP to a MySQL Database. The PHP script finishes successfully, but in the database nothing has changed. So I believe it must have to do with transaction handling. But I start and end the transaction. Does anyone has an idea? Thanks a lot.
<?php
require_once '../extra/pdo_connect.php';
$postdata = file_get_contents("php://input");
if (isset($postdata) && !empty($postdata)) {
$json_obj = json_decode($postdata,true);
$pdo->beginTransaction();
$sql = "delete from user where username = '?'";
$stmt = $pdo->prepare($sql);
$rows = $stmt->execute(array($json_obj['username']));
$echo("Statement executed");
$pdo->commit();
}
?>
As the "Statement executed" is in the Response, the DML and the transaction should have been sucessful.