diff options
author | Ole Ostergaard <ole.ostergaard@knime.com> | 2019-01-21 17:54:40 +0100 |
---|---|---|
committer | Ole Ostergaard <ole.c.ostergaard@gmail.com> | 2019-03-21 11:42:00 +0100 |
commit | c9b6487393f1272f554cd54ea5707a43bd80d953 (patch) | |
tree | 2a9d4d5694c3a4cd7533c6b25c08d816c2491420 /lib/private | |
parent | a48ea8cffa68540b704bead86456008d6978a91b (diff) | |
download | nextcloud-server-c9b6487393f1272f554cd54ea5707a43bd80d953.tar.gz nextcloud-server-c9b6487393f1272f554cd54ea5707a43bd80d953.zip |
Add PostgreSQL specific implementation for includeIgnoreConflict.
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/DB/AdapterPgSql.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php index 47ef4dff037..86f2fe2e384 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); + } } |