From c9b6487393f1272f554cd54ea5707a43bd80d953 Mon Sep 17 00:00:00 2001 From: Ole Ostergaard Date: Mon, 21 Jan 2019 17:54:40 +0100 Subject: [PATCH] Add PostgreSQL specific implementation for includeIgnoreConflict. Signed-off-by: Ole Ostergaard --- lib/private/DB/AdapterPgSql.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php index 47ef4dff03..86f2fe2e38 100644 --- a/lib/private/DB/AdapterPgSql.php +++ b/lib/private/DB/AdapterPgSql.php @@ -35,4 +35,16 @@ class AdapterPgSql extends Adapter { $statement = str_ireplace( 'UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement ); return $statement; } + + public function insertIgnoreConflict($table, $input) : int { + $builder = $this->conn->getQueryBuilder(); + $builder->insert($table) + ->values($input); + foreach($input as $key => $value) { + $builder->setValue($key, $builder->createNamedParameter($value)); + } + $queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING'; + $inserts = array_values($input); + return $this->conn->executeUpdate($queryString, $inserts); + } }