All,
I have another issue which I'm stumped on. I have code that checks form input data against an sqlite3 database and inserts the data if the data is not there. Issue is that it locks the database for ~1 minute and does not insert the data.
$addYes = 1;
$app = "ddns";
$addApp = strtoupper($app);
if (isset($addYes)){
$addApp = strtoupper($app);
$dbc = new PDO('sqlite:/var/www/l56/l56.sq3');
$dbc->beginTransaction();
$sql = "select count(app) as app FROM app where app = \"$addApp\"";
$result = $dbc->query($sql);
$dbc->commit();
$dbc = null;
foreach ($result as $row){
if (!$row['app']) {
$dba = new PDO('sqlite:/var/www/l56/l56.sq3');
$dba->beginTransaction();
$sql = "insert into app values(NULL,\"$addApp\")";
$dba->query($sql);
$dba->commit();
$error = "$sql";
$dba = null;
} else { $error = "App exists"; }
}
}
The code works without issue if the query returns a match. Alone, the insert works, even with a delete immediately after:
$dba = new PDO('sqlite:/var/www/l56/l56.sq3');
$dba->beginTransaction();
$sql = "insert into app values(NULL,\"$addApp\")";
$dba->query($sql);
$dba->commit();
$error = $sql;
$dba = new PDO('sqlite:/var/www/l56/l56.sq3');
$dba->beginTransaction();
$sql = "delete from app where app = \"$addApp\"";
$dba->query($sql);
$dba->commit();
What am I missing? Any clues?
Thanks!