diff options
author | Ole Ostergaard <ole.ostergaard@knime.com> | 2019-01-21 17:54:16 +0100 |
---|---|---|
committer | Ole Ostergaard <ole.c.ostergaard@gmail.com> | 2019-03-21 11:42:00 +0100 |
commit | a48ea8cffa68540b704bead86456008d6978a91b (patch) | |
tree | ae136c49e1a8c24744a1d21c65b777a0ea9b53c7 /lib/private/DB/Adapter.php | |
parent | 0155edc195ed278a2a4d06c15295433ae0ae8445 (diff) | |
download | nextcloud-server-a48ea8cffa68540b704bead86456008d6978a91b.tar.gz nextcloud-server-a48ea8cffa68540b704bead86456008d6978a91b.zip |
Add insertIgnoreConflict to Adapter and use it for for executing the file locking.
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Diffstat (limited to 'lib/private/DB/Adapter.php')
-rw-r--r-- | lib/private/DB/Adapter.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index b9a5f272c57..139b7828596 100644 --- a/lib/private/DB/Adapter.php +++ b/lib/private/DB/Adapter.php @@ -126,4 +126,17 @@ class Adapter { return 0; } } + + public function insertIgnoreConflict($table, $input) : int { + try { + $builder = $this->conn->getQueryBuilder(); + $builder->insert($table); + foreach($input as $key => $value) { + $builder->setValue($key, $builder->createNamedParameter($value)); + } + return $builder->execute(); + } catch(UniqueConstraintViolationException $e) { + return 0; + } + } } |