I am using sqlite and trying to connect to it through my PHP script. The select query is working but the update query is not working Please find below the code snippet
$dir = 'sqlite:/var/www/html/BMKAOAData.db';
$dbh = new PDO($dir) or die("cannot open the database");
$query = 'update KAOAData set comments = :Comments where aptNo = :aptNo';
$stmt= $dbh->prepare($query);
if(!$stmt){
echo "
PDO::errorInfo():
";
print_r($dbh->errorInfo());
}
$stmt->bindParam(':Comments',$myComments,PDO::PARAM_STR);
$stmt->bindParam(':aptNo',$myaptNo,PDO::PARAM_STR);
$stmt->execute();
$count = $stmt->rowCount();
print "Updated $count rows
";
I searched a lot for its solution and tried various methods but couldn't resolve it. Note that I have the database in the same directory of the script and I have given right permission to it and all its parent directory. I am executing the same query in sqlite prompt and it is working fine. Please help to resolve this.
Maybe is the database autocommit set to false? In that case
$dbh->commit();
could solve your issue