Add PostgreSQL specific implementation for includeIgnoreConflict.

Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
This commit is contained in:
Ole Ostergaard 2019-01-21 17:54:40 +01:00 committed by Ole Ostergaard
parent a48ea8cffa
commit c9b6487393
1 changed files with 12 additions and 0 deletions

View 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);
}
}