i try to do 2 ajax call with php and jquery that insert data into my sqlite database, the first insert call works fine,but when the second call start,the server respond: database is locked
the two ajax requests start at the same time,They are simultaneous.
how i can solve it?
here's my php code:
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('../copiaDatabase.sqlite');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$opera=$_POST["opera"];
$codiceBeacon=$_POST["codice"];
$museo= (string)$_POST["museo"];
$codice_qr_random=$_POST["codice_qr_random"];
$sql = <<<EOF
INSERT INTO 'selectedObject' (museum , atwork , beaconCode , qrCode)
VALUES ('$museo' , '$opera', '$codiceBeacon' , '$codice_qr_random');
EOF;
$ret = $db->exec($sql);
if(!$ret){
echo $db->lastErrorMsg();
} else {
echo "Records created successfully\n";
}
$db->close();
?>
and this is my ajax call using jquery:
$.ajax({
type: "POST",
url: "db/liteVersionPhpApplicazione/inserimentoCodiceLite.php",
// data:{opera: opera, codice: codice},
data: {
opera: opera,
codice: codice,
museo: museo,
codice_qr_random: codice_qr_random
},
success: function (data) {
alert(data);
}
})
});
Aucun commentaire:
Enregistrer un commentaire