Code cleanup.
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
This commit is contained in:
parent
63350423d4
commit
0d778fcc4e
|
@ -130,11 +130,11 @@ class Adapter {
|
||||||
/*
|
/*
|
||||||
* @suppress SqlInjectionChecker
|
* @suppress SqlInjectionChecker
|
||||||
*/
|
*/
|
||||||
public function insertIgnoreConflict($table, $input) : int {
|
public function insertIgnoreConflict(string $table,array $values) : int {
|
||||||
try {
|
try {
|
||||||
$builder = $this->conn->getQueryBuilder();
|
$builder = $this->conn->getQueryBuilder();
|
||||||
$builder->insert($table);
|
$builder->insert($table);
|
||||||
foreach($input as $key => $value) {
|
foreach($values as $key => $value) {
|
||||||
$builder->setValue($key, $builder->createNamedParameter($value));
|
$builder->setValue($key, $builder->createNamedParameter($value));
|
||||||
}
|
}
|
||||||
return $builder->execute();
|
return $builder->execute();
|
||||||
|
|
|
@ -39,15 +39,13 @@ class AdapterPgSql extends Adapter {
|
||||||
/*
|
/*
|
||||||
* @suppress SqlInjectionChecker
|
* @suppress SqlInjectionChecker
|
||||||
*/
|
*/
|
||||||
public function insertIgnoreConflict($table, $input) : int {
|
public function insertIgnoreConflict(string $table,array $values) : int {
|
||||||
$builder = $this->conn->getQueryBuilder();
|
$builder = $this->conn->getQueryBuilder();
|
||||||
$builder->insert($table)
|
$builder->insert($table);
|
||||||
->values($input);
|
foreach($values as $key => $value) {
|
||||||
foreach($input as $key => $value) {
|
|
||||||
$builder->setValue($key, $builder->createNamedParameter($value));
|
$builder->setValue($key, $builder->createNamedParameter($value));
|
||||||
}
|
}
|
||||||
$queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING';
|
$queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING';
|
||||||
$inserts = array_values($input);
|
return $this->conn->executeUpdate($queryString, $builder->getParameters(), $builder->getParameterTypes());
|
||||||
return $this->conn->executeUpdate($queryString, $inserts);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,8 +257,8 @@ class Connection extends ReconnectWrapper implements IDBConnection {
|
||||||
return $this->adapter->insertIfNotExist($table, $input, $compare);
|
return $this->adapter->insertIfNotExist($table, $input, $compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insertIgnoreConflict($table, $input) : int {
|
public function insertIgnoreConflict(string $table, array $values) : int {
|
||||||
return $this->adapter->insertIgnoreConflict($table, $input);
|
return $this->adapter->insertIgnoreConflict($table, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getType($value) {
|
private function getType($value) {
|
||||||
|
|
|
@ -131,10 +131,13 @@ class DBLockingProvider extends AbstractLockingProvider {
|
||||||
* @param int $lock
|
* @param int $lock
|
||||||
* @return int number of inserted rows
|
* @return int number of inserted rows
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected function initLockField(string $path, int $lock = 0): int {
|
protected function initLockField(string $path, int $lock = 0): int {
|
||||||
$expire = $this->getExpireTime();
|
$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
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -128,11 +128,11 @@ interface IDBConnection {
|
||||||
* Implementation is not fully finished and should not be used!
|
* Implementation is not fully finished and should not be used!
|
||||||
*
|
*
|
||||||
* @param string $table The table name (will replace *PREFIX* with the actual prefix)
|
* @param string $table The table name (will replace *PREFIX* with the actual prefix)
|
||||||
* @param array $input data that should be inserted into the table (column name => value)
|
* @param array $values data that should be inserted into the table (column name => value)
|
||||||
* @return int number of inserted rows
|
* @return int number of inserted rows
|
||||||
* @since 17.0.0
|
* @since 16.0.0
|
||||||
*/
|
*/
|
||||||
public function insertIgnoreConflict($table, $input) : int;
|
public function insertIgnoreConflict(string $table,array $values) : int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert or update a row value
|
* Insert or update a row value
|
||||||
|
|
Loading…
Reference in New Issue