summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2009-02-14 17:16:39 -0600
committerLoui Chang <louipc.ist@gmail.com>2009-02-15 14:30:35 -0500
commit0caa949e4174ba2fcd144b29795ba98cb6f193af (patch)
treed826a130315241eff9fbd687f5806d8a6a17b892 /web
parent6afc46cb4a536b331e1b13c58d3d8c027367c82f (diff)
downloadaurweb-0caa949e4174ba2fcd144b29795ba98cb6f193af.tar.xz
rpc: delay getting DB connection until absolutely necessary
Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web')
-rw-r--r--web/lib/aurjson.class.php7
1 files changed, 4 insertions, 3 deletions
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);