From 5d1eaa1f741e817e48f1b2e2fc22d40ad04b8e16 Mon Sep 17 00:00:00 2001 From: marcus Date: Tue, 17 Feb 2009 08:29:01 +0000 Subject: Closes #785: datalists now pulls all settings on first item load. git-svn-id: https://code.elgg.org/elgg/trunk@2775 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index c89ab2789..9d677a483 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1690,14 +1690,32 @@ if ($datalist_memcache) $value = $datalist_memcache->load($name); if ($value) return $value; - if ($row = get_data_row("SELECT value from {$CONFIG->dbprefix}datalists where name = '{$name}' limit 1")) { + // [Marcus Povey 20090217 : Now retrieving all datalist values on first load as this saves about 9 queries per page] + $result = get_data("SELECT * from {$CONFIG->dbprefix}datalists"); + if ($result) + { + foreach ($result as $row) + { + $DATALIST_CACHE[$row->name] = $row->value; + + // Cache it if memcache is available + if ($datalist_memcache) $datalist_memcache->save($name, $row->value); + } + + if (isset($DATALIST_CACHE[$name])) + return $DATALIST_CACHE[$name]; + } + + + /*if ($row = get_data_row("SELECT value from {$CONFIG->dbprefix}datalists where name = '{$name}' limit 1")) { $DATALIST_CACHE[$name] = $row->value; // Cache it if memcache is available if ($datalist_memcache) $datalist_memcache->save($name, $row->value); return $row->value; - } + }*/ + return false; } -- cgit v1.2.3