From 4322b56c0bca0a6968869137d5cac88791721664 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 9 Oct 2016 07:18:52 +0000 Subject: [PATCH] Ensure that with multiple entries the newest one will be fetched --- include/Core/Config.php | 4 ++-- include/Core/PConfig.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Core/Config.php b/include/Core/Config.php index e5515efafc..a93f188148 100644 --- a/include/Core/Config.php +++ b/include/Core/Config.php @@ -32,7 +32,7 @@ class Config { public static function load($family) { global $a; - $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s'", dbesc($family)); + $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family)); if(count($r)) { foreach($r as $rr) { $k = $rr['k']; @@ -90,7 +90,7 @@ class Config { } } - $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", + $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1", dbesc($family), dbesc($key) ); diff --git a/include/Core/PConfig.php b/include/Core/PConfig.php index 082f1c05c2..de8994d1de 100644 --- a/include/Core/PConfig.php +++ b/include/Core/PConfig.php @@ -29,7 +29,7 @@ class PConfig { */ public static function load($uid,$family) { global $a; - $r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d", + $r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`", dbesc($family), intval($uid) ); @@ -83,7 +83,7 @@ class PConfig { } } - $ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", + $ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1", intval($uid), dbesc($family), dbesc($key) -- 2.39.5