mirror of
https://github.com/friendica/friendica
synced 2025-04-24 13:10:11 +00:00
Fix Issue #2816
- Change (P)Config::set to use INSERT >>> ON DUPLICATE KEY UPDATE - Add DB update
This commit is contained in:
parent
82dcc3fe79
commit
3c85fb8c9a
3 changed files with 25 additions and 44 deletions
|
@ -126,27 +126,16 @@ class PConfig {
|
|||
// manage array value
|
||||
$dbvalue = (is_array($value)?serialize($value):$value);
|
||||
|
||||
if(is_null(self::get($uid,$family,$key,null, true))) {
|
||||
$a->config[$uid][$family][$key] = $value;
|
||||
$ret = q("INSERT INTO `pconfig` ( `uid`, `cat`, `k`, `v` ) VALUES ( %d, '%s', '%s', '%s' ) ",
|
||||
intval($uid),
|
||||
dbesc($family),
|
||||
dbesc($key),
|
||||
dbesc($dbvalue)
|
||||
);
|
||||
if($ret)
|
||||
return $value;
|
||||
return $ret;
|
||||
}
|
||||
$ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'",
|
||||
dbesc($dbvalue),
|
||||
intval($uid),
|
||||
dbesc($family),
|
||||
dbesc($key)
|
||||
);
|
||||
|
||||
$a->config[$uid][$family][$key] = $value;
|
||||
|
||||
$ret = q("INSERT INTO `pconfig` ( `uid`, `cat`, `k`, `v` ) VALUES ( %d, '%s', '%s', '%s' )
|
||||
ON DUPLICATE KEY UPDATE `v` = '%s'",
|
||||
intval($uid),
|
||||
dbesc($family),
|
||||
dbesc($key),
|
||||
dbesc($dbvalue),
|
||||
dbesc($dbvalue)
|
||||
);
|
||||
if($ret)
|
||||
return $value;
|
||||
return $ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue