Config now works with the new database routines
This commit is contained in:
parent
4d77c8a90a
commit
ae8098eaf2
2 changed files with 24 additions and 38 deletions
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
use dba;
|
||||||
use dbm;
|
use dbm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,17 +46,15 @@ class Config {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s'", dbesc($family));
|
$r = dba::select('config', array('v', 'k'), array('cat' => $family), array("order" => array("cat", "k")));
|
||||||
if (dbm::is_result($r)) {
|
while ($rr = dba::fetch($r)) {
|
||||||
foreach ($r as $rr) {
|
$k = $rr['k'];
|
||||||
$k = $rr['k'];
|
if ($family === 'config') {
|
||||||
if ($family === 'config') {
|
$a->config[$k] = $rr['v'];
|
||||||
$a->config[$k] = $rr['v'];
|
} else {
|
||||||
} else {
|
$a->config[$family][$k] = $rr['v'];
|
||||||
$a->config[$family][$k] = $rr['v'];
|
self::$cache[$family][$k] = $rr['v'];
|
||||||
self::$cache[$family][$k] = $rr['v'];
|
self::$in_db[$family][$k] = true;
|
||||||
self::$in_db[$family][$k] = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,13 +97,11 @@ class Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
|
$ret = dba::select('config', array('v'), array('cat' => $family, 'k' => $key),
|
||||||
dbesc($family),
|
array("order" => array("cat", "k"), 'limit' => 1));
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
if (dbm::is_result($ret)) {
|
if (dbm::is_result($ret)) {
|
||||||
// manage array value
|
// 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
|
// Assign the value from the database to the cache
|
||||||
self::$cache[$family][$key] = $val;
|
self::$cache[$family][$key] = $val;
|
||||||
|
@ -206,11 +203,8 @@ class Config {
|
||||||
unset(self::$cache[$family][$key]);
|
unset(self::$cache[$family][$key]);
|
||||||
unset(self::$in_db[$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;
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
|
use dba;
|
||||||
use dbm;
|
use dbm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,12 +35,11 @@ class PConfig {
|
||||||
*/
|
*/
|
||||||
public static function load($uid, $family) {
|
public static function load($uid, $family) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`",
|
|
||||||
dbesc($family),
|
$r = dba::select('pconfig', array('v', 'k'), array('cat' => $family, 'uid' => $uid),
|
||||||
intval($uid)
|
array("order" => array('uid', 'cat', 'k')));
|
||||||
);
|
|
||||||
if (dbm::is_result($r)) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $rr) {
|
while ($rr = dba::fetch($r)) {
|
||||||
$k = $rr['k'];
|
$k = $rr['k'];
|
||||||
$a->config[$uid][$family][$k] = $rr['v'];
|
$a->config[$uid][$family][$k] = $rr['v'];
|
||||||
self::$in_db[$uid][$family][$k] = true;
|
self::$in_db[$uid][$family][$k] = true;
|
||||||
|
@ -89,14 +89,10 @@ class PConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1",
|
$ret = dba::select('pconfig', array('v'), array('uid' => $uid, 'cat' => $family, 'k' => $key),
|
||||||
intval($uid),
|
array("order" => array('uid', 'cat', 'k'), 'limit' => 1));
|
||||||
dbesc($family),
|
if (dbm::is_result($ret)) {
|
||||||
dbesc($key)
|
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v']) ? unserialize($ret[0]['v']) : $ret[0]['v']);
|
||||||
);
|
|
||||||
|
|
||||||
if (count($ret)) {
|
|
||||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
|
|
||||||
$a->config[$uid][$family][$key] = $val;
|
$a->config[$uid][$family][$key] = $val;
|
||||||
self::$in_db[$uid][$family][$key] = true;
|
self::$in_db[$uid][$family][$key] = true;
|
||||||
|
|
||||||
|
@ -193,11 +189,7 @@ class PConfig {
|
||||||
unset(self::$in_db[$uid][$family][$key]);
|
unset(self::$in_db[$uid][$family][$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'",
|
$ret = dba::delete('pconfig', array('uid' => $uid, 'cat' => $family, 'k' => $key));
|
||||||
intval($uid),
|
|
||||||
dbesc($family),
|
|
||||||
dbesc($key)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue