Maybe there is similar question, but I didn’t find one writed in php.
I have a sql file and I want to import it in sqlite db.
$database = new PDO( 'sqlite:'.$tempdb );
if( $database->exec( $sql ) === false )
{
die( print_r( $database->errorInfo(), true ) );
}
SQL Example:
INSERT INTO table (id,title) VALUES
(1,'title 1'),
(2,'title 2'),
(3, 'more title');
Returns:
Array ( [0] => HY000 [1] => 1 [2] => near ",": syntax error )
The problem appears to be the fact of sqlite uses PDO::bindParams() for insert.
There is any workaround it?
tableis a keyword; you would have to quote it as"table".But assuming that you actual table name is different: Inserting multiple records with one
INSERTcommand is supported only since SQLite 3.7.11; it’s likely that PHP’s built-in SQLite is older.