Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Ostergaard <[email protected]>
  • Loading branch information
oole committed Feb 26, 2019
1 parent 6247745 commit 1b1231c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/private/DB/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public function insertIfNotExist($table, $input, array $compare = null) {
/*
* @suppress SqlInjectionChecker
*/
public function insertIgnoreConflict($table, $input) : int {
public function insertIgnoreConflict($table, $values) : int {
try {
$builder = $this->conn->getQueryBuilder();
$builder->insert($table);
foreach($input as $key => $value) {
foreach($values as $key => $value) {
$builder->setValue($key, $builder->createNamedParameter($value));
}
return $builder->execute();
Expand Down
10 changes: 4 additions & 6 deletions lib/private/DB/AdapterPgSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ public function fixupStatement($statement) {
/*
* @suppress SqlInjectionChecker
*/
public function insertIgnoreConflict($table, $input) : int {
public function insertIgnoreConflict($table, $values) : int {
$builder = $this->conn->getQueryBuilder();
$builder->insert($table)
->values($input);
foreach($input as $key => $value) {
$builder->insert($table);
foreach($values 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);
return $this->conn->executeUpdate($queryString, $builder->getParameters(), $builder->getParameterTypes());
}
}
6 changes: 4 additions & 2 deletions lib/private/Lock/DBLockingProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ public function __construct(
* @param int $lock
* @return int number of inserted rows
*/

protected function initLockField(string $path, int $lock = 0): int {
$expire = $this->getExpireTime();
return $this->connection->insertIgnoreConflict('file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire]);
return $this->connection->insertIgnoreConflict('file_locks', [
'key' => $path,
'lock' => $lock,
'ttl' => $expire]);
}

/**
Expand Down

0 comments on commit 1b1231c

Please sign in to comment.