Skip to content

Commit b58dae6

Browse files
Session: Improve CSV/XML session import with datetime support and code cleanup - refs #3554
1 parent 53d5401 commit b58dae6

File tree

3 files changed

+476
-601
lines changed

3 files changed

+476
-601
lines changed

public/main/inc/lib/database.lib.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public static function store_result(\Doctrine\DBAL\Result $result, $option = 'BO
312312
* @throws \Doctrine\DBAL\Exception
313313
* @throws Exception
314314
*/
315-
public static function insert(string $table_name, array $attributes, bool $show_query = false): bool|int
315+
public static function insert(string $table_name, array $attributes, bool $show_query = false, array $options = []): bool|int
316316
{
317317
if (empty($attributes) || empty($table_name)) {
318318
return false;
@@ -321,8 +321,9 @@ public static function insert(string $table_name, array $attributes, bool $show_
321321
$params = array_keys($attributes);
322322

323323
if (!empty($params)) {
324-
$sql = 'INSERT INTO '.$table_name.' ('.implode(',', $params).')
325-
VALUES (:'.implode(', :', $params).')';
324+
$prefix = (!empty($options['ignore'])) ? 'INSERT IGNORE INTO' : 'INSERT INTO';
325+
$sql = $prefix.' '.$table_name.' ('.implode(',', $params).')
326+
VALUES (:'.implode(', :', $params).')';
326327

327328
if ($show_query) {
328329
var_dump($sql);

0 commit comments

Comments
 (0)