insertIfNotExists() for storage insertion
This commit is contained in:
parent
c917ea183c
commit
940163e16b
|
@ -35,9 +35,15 @@ class Storage {
|
||||||
if ($row = $result->fetchRow()) {
|
if ($row = $result->fetchRow()) {
|
||||||
$this->numericId = $row['numeric_id'];
|
$this->numericId = $row['numeric_id'];
|
||||||
} else {
|
} else {
|
||||||
$sql = 'INSERT INTO `*PREFIX*storages` (`id`) VALUES(?)';
|
$connection = \OC_DB::getConnection();
|
||||||
\OC_DB::executeAudited($sql, array($this->storageId));
|
if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId])) {
|
||||||
$this->numericId = \OC_DB::insertid('*PREFIX*storages');
|
$this->numericId = \OC_DB::insertid('*PREFIX*storages');
|
||||||
|
} else {
|
||||||
|
$result = \OC_DB::executeAudited($sql, array($this->storageId));
|
||||||
|
if ($row = $result->fetchRow()) {
|
||||||
|
$this->numericId = $row['numeric_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue