$ref]); if (!DBA::isResult($r)) { return ''; } return $r['data']; } public static function put($data, $ref = '') { if ($ref !== '') { $r = DBA::update('storage', ['data' => $data], ['id' => $ref]); if ($r === false) { Logger::log('Failed to update data with id ' . $ref . ': ' . DBA::errorNo() . ' : ' . DBA::errorMessage()); throw new StorageException(L10n::t('Database storage failed to update %s', $ref)); } return $ref; } else { $r = DBA::insert('storage', ['data' => $data]); if ($r === false) { Logger::log('Failed to insert data: ' . DBA::errorNo() . ' : ' . DBA::errorMessage()); throw new StorageException(L10n::t('Database storage failed to insert data')); } return DBA::lastInsertId(); } } public static function delete($ref) { return DBA::delete('storage', ['id' => $ref]); } }