Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions public/main/inc/lib/database.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public static function store_result(\Doctrine\DBAL\Result $result, $option = 'BO
* @throws \Doctrine\DBAL\Exception
* @throws Exception
*/
public static function insert(string $table_name, array $attributes, bool $show_query = false): bool|int
public static function insert(string $table_name, array $attributes, bool $show_query = false, array $options = []): bool|int
{
if (empty($attributes) || empty($table_name)) {
return false;
Expand All @@ -321,8 +321,9 @@ public static function insert(string $table_name, array $attributes, bool $show_
$params = array_keys($attributes);

if (!empty($params)) {
$sql = 'INSERT INTO '.$table_name.' ('.implode(',', $params).')
VALUES (:'.implode(', :', $params).')';
$prefix = (!empty($options['ignore'])) ? 'INSERT IGNORE INTO' : 'INSERT INTO';
$sql = $prefix.' '.$table_name.' ('.implode(',', $params).')
VALUES (:'.implode(', :', $params).')';

if ($show_query) {
var_dump($sql);
Expand Down
Loading
Loading