@@ -324,12 +324,12 @@ public function fetchAll(string $sql): array
324324 /**
325325 * Get the parameters array for prepared insert statement
326326 *
327+ * @param array $params Parameters array to be filled
327328 * @param array $row Row to be inserted into DB
328329 * @return array
329330 */
330- protected function getInsertParameters (array $ row ): array
331+ protected function getInsertParameters (array & $ params , array $ row ): void
331332 {
332- $ params = [];
333333 foreach ($ row as $ value ) {
334334 if ($ value instanceof Literal) {
335335 continue ;
@@ -343,8 +343,6 @@ protected function getInsertParameters(array $row): array
343343 $ params [] = $ value ;
344344 }
345345 }
346-
347- return $ params ;
348346 }
349347
350348 /**
@@ -374,7 +372,8 @@ public function insert(Table $table, array $row): void
374372 foreach ($ row as $ value ) {
375373 $ values [] = $ value instanceof Literal ? (string )$ value : '? ' ;
376374 }
377- $ params = $ this ->getInsertParameters ($ row );
375+ $ params = [];
376+ $ this ->getInsertParameters ($ params , $ row );
378377 $ sql .= implode (', ' , $ values ) . ') ' ;
379378 $ stmt = $ this ->getConnection ()->prepare ($ sql );
380379 $ stmt ->execute ($ params );
@@ -445,10 +444,10 @@ public function bulkinsert(Table $table, array $rows): void
445444 }
446445 $ sql .= implode (', ' , $ queries );
447446 $ stmt = $ this ->getConnection ()->prepare ($ sql );
448- $ params = [];
449447
448+ $ params = [];
450449 foreach ($ rows as $ row ) {
451- $ params = array_merge ( $ params , $ this ->getInsertParameters ($ row) );
450+ $ this ->getInsertParameters ($ params , $ row );
452451 }
453452
454453 $ stmt ->execute ($ params );
0 commit comments