From 551457f2b618980ebff3dbfea364a8a666f21e62 Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 17 Jul 2019 11:15:59 +0200 Subject: [PATCH] fixes #1051 ability to insert ignore on single_insert --- include/dblayer/functions_mysqli.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/dblayer/functions_mysqli.inc.php b/include/dblayer/functions_mysqli.inc.php index 030a01a3d..7ec6ab8ac 100644 --- a/include/dblayer/functions_mysqli.inc.php +++ b/include/dblayer/functions_mysqli.inc.php @@ -574,9 +574,17 @@ INSERT '.$ignore.' INTO '.$table_name.' * * @param string $table_name * @param array $data + * @param array $options + * - boolean ignore - use "INSERT IGNORE" */ -function single_insert($table_name, $data) +function single_insert($table_name, $data, $options=array()) { + $ignore = ''; + if (isset($options['ignore']) and $options['ignore']) + { + $ignore = 'IGNORE'; + } + if (count($data) != 0) { // escape a reserved word @@ -586,7 +594,7 @@ function single_insert($table_name, $data) } $query = ' -INSERT INTO '.$table_name.' +INSERT '.$ignore.' INTO '.$table_name.' ('.implode(',', array_keys($data)).') VALUES';