3 * @file src/Model/Storage/Filesystem.php
4 * @brief Storage backend system
7 namespace Friendica\Model\Storage;
9 use Friendica\Core\Logger;
10 use Friendica\Core\L10n;
11 use Friendica\Database\DBA;
14 * @brief Database based storage system
16 * This class manage data stored in database table.
18 class Database implements IStorage
20 public static function get($ref)
22 $r = DBA::selectFirst('storage', ['data'], ['id' => $ref]);
23 if (!DBA::isResult($r)) {
30 public static function put($data, $ref = '')
33 $r = DBA::update('storage', ['data' => $data], ['id' => $ref]);
35 Logger::log('Failed to update data with id ' . $ref . ': ' . DBA::errorNo() . ' : ' . DBA::errorMessage());
36 throw new StorageException(L10n::t('Database storage failed to update %s', $ref));
40 $r = DBA::insert('storage', ['data' => $data]);
42 Logger::log('Failed to insert data: ' . DBA::errorNo() . ' : ' . DBA::errorMessage());
43 throw new StorageException(L10n::t('Database storage failed to insert data'));
45 return DBA::lastInsertId();
49 public static function delete($ref)
51 return DBA::delete('storage', ['id' => $ref]);
54 public static function getOptions()
59 public static function saveOptions($data)