<?php
namespace Friendica\Core;
+use dba;
use dbm;
/**
$a = get_app();
- $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s'", dbesc($family));
- if (dbm::is_result($r)) {
- foreach ($r as $rr) {
- $k = $rr['k'];
- if ($family === 'config') {
- $a->config[$k] = $rr['v'];
- } else {
- $a->config[$family][$k] = $rr['v'];
- self::$cache[$family][$k] = $rr['v'];
- self::$in_db[$family][$k] = true;
- }
+ $r = dba::select('config', array('v', 'k'), array('cat' => $family), array("order" => array("cat", "k")));
+ while ($rr = dba::fetch($r)) {
+ $k = $rr['k'];
+ if ($family === 'config') {
+ $a->config[$k] = $rr['v'];
+ } else {
+ $a->config[$family][$k] = $rr['v'];
+ self::$cache[$family][$k] = $rr['v'];
+ self::$in_db[$family][$k] = true;
}
}
}
}
}
- $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
- dbesc($family),
- dbesc($key)
- );
+ $ret = dba::select('config', array('v'), array('cat' => $family, 'k' => $key),
+ array("order" => array("cat", "k"), 'limit' => 1));
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']);
+ $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
// Assign the value from the database to the cache
self::$cache[$family][$key] = $val;
unset(self::$cache[$family][$key]);
unset(self::$in_db[$family][$key]);
}
- $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
- dbesc($family),
- dbesc($key)
- );
+ $ret = dba::delete('config', array('cat' => $family, 'k' => $key));
return $ret;
}
}