aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-13 10:35:11 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-13 10:35:11 +0000
commite1fd499100ce5314982d8ebb83a8db10814d5d4a (patch)
tree72ebb45e8bb84df69c90d1c06d53c3cf90432804
parentac2d81526779f2f1ff9486922bed41f4a4579947 (diff)
downloadelgg-e1fd499100ce5314982d8ebb83a8db10814d5d4a.tar.gz
elgg-e1fd499100ce5314982d8ebb83a8db10814d5d4a.tar.bz2
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
-rw-r--r--engine/lib/database.php15
1 files changed, 10 insertions, 5 deletions
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))