From 0caa949e4174ba2fcd144b29795ba98cb6f193af Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 14 Feb 2009 17:16:39 -0600 Subject: rpc: delay getting DB connection until absolutely necessary Signed-off-by: Dan McGee Signed-off-by: Loui Chang --- web/lib/aurjson.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'web/lib/aurjson.class.php') diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index 81c0831..425748d 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -33,8 +33,6 @@ class AurJSON { public function handle($http_data) { // set content type header to json header('content-type: application/json'); - // set up db connection. - $this->dbh = db_connect(); // handle error states if ( !isset($http_data['type']) || !isset($http_data['arg']) ) { @@ -43,6 +41,9 @@ class AurJSON { // do the routing if ( in_array($http_data['type'], $this->exposed_methods) ) { + // set up db connection. + $this->dbh = db_connect(); + // ugh. this works. I hate you php. $json = call_user_func_array(array(&$this,$http_data['type']), $http_data['arg']); @@ -103,7 +104,7 @@ class AurJSON { $search_data = array(); while ( $row = mysql_fetch_assoc($result) ) { array_push($search_data, $row); - } + } mysql_free_result($result); return $this->json_results('search', $search_data); -- cgit v1.2.3-70-g09d2