summaryrefslogtreecommitdiffstats
path: root/lib/SQL.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/SQL.php')
-rw-r--r--lib/SQL.php101
1 files changed, 51 insertions, 50 deletions
diff --git a/lib/SQL.php b/lib/SQL.php
index 6bcf7ed..af1968b 100644
--- a/lib/SQL.php
+++ b/lib/SQL.php
@@ -1,61 +1,62 @@
<?php
- class SQL {
- static private $instance = Array();
-
- private $sql_uri = "mysql://username:password@hostname/database";
-
- /* Placeholder for the existing MySQL connection */
- private $conn = FALSE;
-
- private $sql_stats = Array(
- 'queries' => 0,
- 'query_time' => 0,
- 'connections' => 0
- );
-
- /**
- * This implements the 'singleton' design pattern
- *
- * @return SQL The one and only instance associated with $_conn
- */
- static function get_instance($_conn = 'kolab_wap')
- {
- if (!isset(self::$instance[$_conn])) {
- self::$instance[$_conn] = new SQL($_conn);
- }
-
- return self::$instance[$_conn];
+class SQL {
+ static private $instance = array();
+
+ private $sql_uri = "mysql://username:password@hostname/database";
+
+ /* Placeholder for the existing MySQL connection */
+ private $conn = FALSE;
+
+ private $sql_stats = array(
+ 'queries' => 0,
+ 'query_time' => 0,
+ 'connections' => 0
+ );
+
+ /**
+ * This implements the 'singleton' design pattern
+ *
+ * @return SQL The one and only instance associated with $_conn
+ */
+ static function get_instance($_conn = 'kolab_wap')
+ {
+ if (!isset(self::$instance[$_conn])) {
+ self::$instance[$_conn] = new SQL($_conn);
}
- public function __construct($_conn = 'kolab_wap') {
- $this->name = $_conn;
- $conf = Conf::get_instance();
- $this->sql_uri = $conf->get($_conn, 'sql_uri');
- }
+ return self::$instance[$_conn];
+ }
- public function query($query) {
- if (!$this->conn) {
- $this->_connect();
- }
+ public function __construct($_conn = 'kolab_wap')
+ {
+ $this->name = $_conn;
+ $conf = Conf::get_instance();
+ $this->sql_uri = $conf->get($_conn, 'sql_uri');
+ }
- $result = mysql_query($query);
- return $result;
+ public function query($query)
+ {
+ if (!$this->conn) {
+ $this->_connect();
}
- private function _connect() {
- if (!$this->conn) {
- $_uri = parse_url($this->sql_uri);
- $this->_username = $_uri['user'];
- $this->_password = $_uri['pass'];
- $this->_hostname = $_uri['host'];
- $this->_database = str_replace('/','',$_uri['path']);
-
- $this->conn = mysql_connect($this->_hostname, $this->_username, $this->_password);
- mysql_select_db($this->_database, $this->conn);
- }
- }
+ $result = mysql_query($query);
+ return $result;
+ }
+ private function _connect()
+ {
+ if (!$this->conn) {
+ $_uri = parse_url($this->sql_uri);
+ $this->_username = $_uri['user'];
+ $this->_password = $_uri['pass'];
+ $this->_hostname = $_uri['host'];
+ $this->_database = str_replace('/','',$_uri['path']);
+
+ $this->conn = mysql_connect($this->_hostname, $this->_username, $this->_password);
+ mysql_select_db($this->_database, $this->conn);
+ }
}
-?>
+}