- attached Screenshot from 2018-04-13 12-00-40.png
- attached Screenshot from 2018-04-13 12-02-52.png
- attached Screenshot from 2018-04-13 12-22-38.png
INSERT ... SELECT ... duplicating rows
Running on Synology, 1.9.8-dev, php7
Trying the captioned syntax. There should only be a single row insert, but 2 rows always inserted.
Same statement tried in Sliteman running on Ubuntu only inserts a single row.
Screenshot ...12-00-04
shows the phpsqliteadmin screen with the SQL statement.
Screenshot ...12-02-52
shows the resulting table (the table was empty before the SQL statement). Note two rows with the same data.
A similar statement was run from a php file targetting the same database. The php file contained
<?php
$root='..';
$db_loc = "$root/central/db.sqlite3";
$db=new SQLite3($db_loc);
$db->exec('INSERT INTO transactions (client, unit, operator ) SELECT 1,2,3');
Screenshot ...12-22-38
shows shows the table after the php file was run. Note only one row.
It seems that the problem is with phpliteadmin
processing SQL statements (maybe only Synology because I haven't tried this on a server running under another OS).
The INSERT ... VALUES syntax yields the same result as INSERT ... SELECT
Comments (6)
-
-
repo owner Sorry for not responding yet. Mmh, this is strange. I tried to reproduce it, but so far, was not able to. Do you still have this problem?
-
repo owner - changed milestone to 1.9.9
-
repo owner I could reproduce this now. It happens with the SQLite3 driver, not with the PDO driver.
-
repo owner This is because SQLite3Result::fetchArray executes the query again if the result is empty as pointed out by paule-panke on https://www.php.net/manual/de/sqlite3result.fetcharray.php
-
repo owner - changed status to resolved
- Log in to comment