Answer the question
In order to leave comments, you need to log in
Why is the insertion into the database duplicated?
$dbh = new PDO('sqlite:'.$filename);
$dbh->exec("INSERT INTO test VALUES ('test1')");
$dbh->exec("INSERT INTO test VALUES ('test2')");
$sth = $dbh->query('SELECT * FROM test');
$sth->setFetchMode(PDO::FETCH_ASSOC);
while($row = $sth->fetch()) print_r($row);
$dbh = new PDO('sqlite:'.$filename);
$sth = $dbh->query('SELECT * FROM test');
while($row = $sth->fetch()) print_r($row);
Answer the question
In order to leave comments, you need to log in
In general, I tried to do this with a new base - the insert is duplicated. Most of all, it is not clear why, if you first make an insert, and then only do a select, then the data is still inserted. I tried to work with the database through PDO and directly with SQLite3 - the result is the same. I'm inclined to believe that the glitch is somewhere on the server side.
As a result, the glitch was found on the server side. There were some strange rules in htaccess that, along with any file, always launched index.php.
Not familiar with sqlite, but is the field you're inserting a value into a key field?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question