Answer the question
In order to leave comments, you need to log in
PDO error when working with SQLite?
When I make multiple requests at once, PDO always complains that the number of parameters doesn't match. But if you make single requests, then everything is ok.
$PDO = new \PDO(
'sqlite:' . L_INIL_DB::$pathToFileDB,
null,
null,
);
$query = 'INSERT INTO table (idGame, idChannel, dateU) VALUES (:iG1, :iC1, :dU1); INSERT INTO table (idGame, idChannel, dateU) VALUES (:iG2, :iC2, :dU2);';
$stm = $PDO->prepare($query);
$a1 = 111;
$a2 = 444;
$stm->bindParam(':iG1', $a1, PDO::PARAM_INT);
$stm->bindParam(':iC1', $a1, PDO::PARAM_INT);
$stm->bindParam(':dU1', $a1, PDO::PARAM_INT);
$stm->bindParam(':iG2', $a2, PDO::PARAM_INT);
$stm->bindParam(':iC2', $a2, PDO::PARAM_INT);
$stm->bindParam(':dU2', $a2, PDO::PARAM_INT);
$stm->execute();
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 25 column index out of range in
Answer the question
In order to leave comments, you need to log in
probably not possible in sqlite inside a query ; use?
if you need to speed up the insert, use transactions before inserting a bunch of rows $PDO->beginTransaction() and after respectively $PDO->commit();
If you really need several inserts with just one query, instead of inserting a heap of inserts, try to write one that inserts the result of the next select, and in turn, use union all to collect selects with constants:
INSERT INTO table (idGame, idChannel, dateU)
SELECT :iG1, :iC1, :dU1
UNION ALL
SELECT :iG2, :iC2, :dU2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question