I am stuck I don't know why I am getting this error. My select query working properly and give me result and when i try to upadte its give me
SQLSTATE[HY000]: General error: 5 database is locked
Print value of update query and its working directly in mysqlite
UPDATE settings SET ViewMode = 5,ZoomAmount = 1,PixelRatio = 1 WHERE idFile = 3
I also refer this link but nothing happen
Sqlite3, SQLSTATE[HY000]: General error: 5 database is locked
Here is my code
ini_set('max_execution_time', 300);
try {
/* * *************************************
* Create databases and *
* open connections *
* ************************************ */
// Create (connect to) SQLite database in file
$file_db = new PDO('sqlite:/home/guest/.kodi/userdata/Database/MyVideos93.db');
// Set errormode to exceptions
$file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/* * ************************************
* Play with databases and tables *
* ************************************ */
// pattern for 3D
$pattern = "([-. _](3D|sbs|HSBS|tab|HTAB))i";
// Select idFile,strFilenamedata from file db files table
$result = $file_db->query('SELECT idFile,strFilename FROM files');
/* Begin a transaction, turning off autocommit */
foreach ($result as $data) {
// condition to check 3D movie
if (!empty($data['strFilename']) && !empty($data['idFile'])) {
if (preg_match($pattern, $data['strFilename'])) {
$id = $data['idFile'];
// Prepare Update statement to MyVideos93 file db
$file_db->beginTransaction();
$update = "UPDATE settings SET ViewMode = :ViewMode,ZoomAmount = :ZoomAmount,PixelRatio = :PixelRatio WHERE idFile = :idFile";
$stmt = $file_db->prepare($update);
if ($stmt === false) {
echo "\nPDO::errorInfo():\n";
print_r($file_db->errorInfo());
}
// Bind parameters to statement variables
$stmt->bindParam(':ViewMode', 5, PDO::PARAM_INT);
$stmt->bindParam(':ZoomAmount', 1, PDO::PARAM_INT);
$stmt->bindParam(':PixelRatio', 1, PDO::PARAM_INT);
$stmt->bindParam(':idFile', $id, PDO::PARAM_INT);
$stmt->execute();
sleep(1);
$file_db->commit();
$file_db->exec('UNLOCK settings');
}
/* Database connection is now back in autocommit mode */
}
}
} catch (PDOException $e) {
// Print PDOException message
echo $e->getMessage();
}
$file_db->close();
unset($file_db);