<?php
namespace Friendica\Core;
+
+use dbm;
+
/**
* @file include/Core/Config.php
*
* @return void
*/
public static function load($family) {
- global $a;
+ $a = get_app();
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
- if (count($r)) {
+ if (dbm::is_result($r)) {
foreach ($r as $rr) {
$k = $rr['k'];
if ($family === 'config') {
*/
public static function get($family, $key, $default_value = null, $refresh = false) {
- global $a;
+ $a = get_app();
if (!$refresh) {
// Looking if the whole family isn't set
dbesc($family),
dbesc($key)
);
- if (count($ret)) {
+ if (dbm::is_result($ret)) {
// manage array value
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
$a->config[$family][$key] = $val;
* @return mixed Stored $value or false if the database update failed
*/
public static function set($family, $key, $value) {
- global $a;
+ $a = get_app();
$stored = self::get($family, $key);
$a->config[$family][$key] = $value;
// manage array value
- $dbvalue = (is_array($value) ? serialize($value):$value);
+ $dbvalue = (is_array($value) ? serialize($value) : $value);
$dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue);
if (is_null($stored)) {
*/
public static function delete($family, $key) {
- global $a;
+ $a = get_app();
if (x($a->config[$family],$key)) {
unset($a->config[$family][$key]);
}