Skip to content

Commit 3b32300

Browse files
committed
Add PostgreSQL specific implementation for includeIgnoreConflict.
Signed-off-by: Ole Ostergaard <ole.ostergaard@knime.com>
1 parent 9de9ad2 commit 3b32300

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/private/DB/AdapterPgSql.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,16 @@ public function fixupStatement($statement) {
3535
$statement = str_ireplace( 'UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement );
3636
return $statement;
3737
}
38+
39+
public function insertIgnoreConflict($table, $input) : int {
40+
$builder = $this->conn->getQueryBuilder();
41+
$builder->insert($table)
42+
->values($input);
43+
foreach($input as $key => $value) {
44+
$builder->setValue($key, $builder->createNamedParameter($value));
45+
}
46+
$queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING';
47+
$inserts = array_values($input);
48+
return $this->conn->executeUpdate($queryString, $inserts);
49+
}
3850
}

0 commit comments

Comments
 (0)