]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add PostgreSQL specific implementation for includeIgnoreConflict.
authorOle Ostergaard <ole.ostergaard@knime.com>
Mon, 21 Jan 2019 16:54:40 +0000 (17:54 +0100)
committerOle Ostergaard <ole.c.ostergaard@gmail.com>
Thu, 21 Mar 2019 10:42:00 +0000 (11:42 +0100)
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
lib/private/DB/AdapterPgSql.php

index 47ef4dff0378d634996ba5396e828444b2ac4d7f..86f2fe2e38423bf06ae44b1fbea71440c35db1da 100644 (file)
@@ -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);
+       }
 }