From e1fd499100ce5314982d8ebb83a8db10814d5d4a Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 13 Feb 2009 10:35:11 +0000 Subject: Added lazy database connections to delay establishing the db link until actually required - will allow for future lite/static content endpoints that bypass db connections and session creation. git-svn-id: https://code.elgg.org/elgg/trunk@2733 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/database.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'engine/lib/database.php') diff --git a/engine/lib/database.php b/engine/lib/database.php index 74cf13216..cd08d9d48 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -137,7 +137,7 @@ function init_db($event, $object_type, $object = null) { register_shutdown_function('db_delayedexecution_shutdown_hook'); register_shutdown_function('db_profiling_shutdown_hook'); - setup_db_connections(); + //setup_db_connections(); // [Marcus Povey 20090213: Db connection moved to first db connection attempt] return true; } @@ -151,12 +151,17 @@ global $dblink; + if (isset($dblink[$dblinktype])) { return $dblink[$dblinktype]; - } else { + } else if (isset($dblink['readwrite'])) { return $dblink['readwrite']; } - + else + { + setup_db_connections(); + return get_db_link($dblinktype); + } } /** @@ -180,8 +185,8 @@ */ function execute_query($query, $dblink) { - global $CONFIG, $dbcalls, $DB_PROFILE, $DB_QUERY_CACHE; - + global $CONFIG, $dbcalls, $DB_PROFILE, $DB_QUERY_CACHE; + $dbcalls++; //if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) -- cgit v1.2.3