3 namespace Friendica\Model\Config;
5 use Friendica\Database\Database;
7 abstract class DbaConfig
12 public function __construct(Database $dba)
18 * Checks if the model is currently connected
22 public function isConnected()
24 return $this->dba->isConnected();
28 * Formats a DB value to a config value
29 * - null = The db-value isn't set
30 * - bool = The db-value is either '0' or '1'
31 * - array = The db-value is a serialized array
32 * - string = The db-value is a string
34 * Keep in mind that there aren't any numeric/integer config values in the database
36 * @param null|string $value
38 * @return null|array|string
40 protected function toConfigValue($value)
48 case preg_match("|^a:[0-9]+:{.*}$|s", $value):
49 return unserialize($value);
57 * Formats a config value to a DB value (string)
63 protected function toDbValue($value)
65 // if not set, save an empty string
72 case is_array($value):
73 return serialize($value);
76 return (string)$value;