php sqlite - copy table to another database -
i want copy table db file fail , can't why. code:
$db = new sqlite3($_server['document_root']."/db/098765.db"); $sql = "attach database 'admin.db' admin ; insert 'table-1' select * 'admin.table-1';"; $db->query($sql);
i've read questions on topic on site, no answer helped me.
giving full path attach database doesn't work. creating table before inserting data doesn't work.
properly quote database object identifiers (table/column names etc) in
insert
statement. use use double quotes instead of single ones, string literals. better yet don't use dashes or other restricted characters in object names if possible (stick alphanumerics , underscore).use
exec()
instead ofquery()
$dbpath = $_server['document_root']; $admindbpath = $dbpath; // or else $db = new sqlite3("$dbpath/db/098765.db"); $db->exec("attach database '$admindbpath/admin.db' admin"); $db->exec('insert "table-1" select * admin."table-1"'); ^^^^ ^ ^ ^ ^
Comments
Post a Comment