*
* This class manage data stored in database table.
*/
-class Database implements ISelectableStorage
+class Database implements IWritableStorage
{
const NAME = 'Database';
return $result['data'];
} catch (Exception $exception) {
- throw new StorageException(sprintf('Database storage failed to get %s', $reference), $exception->getCode(), $exception);
+ if ($exception instanceof ReferenceStorageException) {
+ throw $exception;
+ } else {
+ throw new StorageException(sprintf('Database storage failed to get %s', $reference), $exception->getCode(), $exception);
+ }
}
}
public function delete(string $reference)
{
try {
- if (!$this->dba->delete('storage', ['id' => $reference])) {
+ if (!$this->dba->delete('storage', ['id' => $reference]) || $this->dba->affectedRows() === 0) {
throw new ReferenceStorageException(sprintf('Database storage failed to delete %s', $reference));
}
} catch (Exception $exception) {
- throw new StorageException(sprintf('Database storage failed to delete %s', $reference), $exception->getCode(), $exception);
+ if ($exception instanceof ReferenceStorageException) {
+ throw $exception;
+ } else {
+ throw new StorageException(sprintf('Database storage failed to delete %s', $reference), $exception->getCode(), $exception);
+ }
}
}
- /**
- * @inheritDoc
- */
- public function getOptions(): array
- {
- return [];
- }
-
- /**
- * @inheritDoc
- */
- public function saveOptions(array $data): array
- {
- return [];
- }
-
/**
* @inheritDoc
*/