php error : SQLSTATE[HY000]: General error: 6 database table is locked
(1) By anonymous on 2021-03-21 22:49:28 [link] [source]
Hello, I'm beginner in SQL/PHP, I have this php error when I execute the query :
$statement = $pdo->exec("CREATE TABLE t1_backup AS SELECT $columns FROM $tableName;DROP TABLE $tableName;ALTER TABLE t1_backup RENAME TO $tableName;");
Whereas it works if I manually execute the query... What's the problem ?? Thank you !
(2) By Larry Brasfield (larrybr) on 2021-03-22 00:08:07 in reply to 1 [link] [source]
I doubt you got that past the SQLite parser manually either. Those $-prefixed identifiers should not be allowed. Maybe if you look at what those PHP variables expand to, the problem will become evident.
(3) By Stephan Beal (stephan) on 2021-03-22 00:31:15 in reply to 1 [source]
Whereas it works if I manually execute the query... What's the problem ?
Unless PDO has changed significantly in the 8+ years since i last used it, exec() supports only a single statement, whereas you have given it several statements. How to use the various PHP sqlite APIs is far out of scope here, though - this forum is for the C library and its close relatives.