diff options
author | friendica <info@friendica.com> | 2011-11-25 22:41:50 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2011-11-25 22:41:50 -0800 |
commit | 0f4a42f550b5bc863cec7c7a3fca26a028599dcc (patch) | |
tree | f86801eac577e77ee654d9b0365037a4b558f500 /include/dba.php | |
parent | 6b93324c11439e739bfe32e0be6ddd07f72ea294 (diff) | |
download | volse-hubzilla-0f4a42f550b5bc863cec7c7a3fca26a028599dcc.tar.gz volse-hubzilla-0f4a42f550b5bc863cec7c7a3fca26a028599dcc.tar.bz2 volse-hubzilla-0f4a42f550b5bc863cec7c7a3fca26a028599dcc.zip |
start on bug #227 - more to do
Diffstat (limited to 'include/dba.php')
-rw-r--r-- | include/dba.php | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/include/dba.php b/include/dba.php index 70c27515c..e9d47cd1a 100644 --- a/include/dba.php +++ b/include/dba.php @@ -36,11 +36,19 @@ class dba { } } - $this->db = @new mysqli($server,$user,$pass,$db); - if(! mysqli_connect_errno()) { - $this->connected = true; + if(class_exists('mysqli')) { + $this->db = @new mysqli($server,$user,$pass,$db); + if(! mysqli_connect_errno()) { + $this->connected = true; + } } else { + $this->db = mysql_connect($server,$user,$pass); + if($this->db && mysql_select_db($db,$this->db)) { + $this->connected = true; + } + } + if(! $this->connected) { $this->db = null; if(! $install) system_unavailable(); @@ -56,14 +64,19 @@ class dba { if((! $this->db) || (! $this->connected)) return false; - $result = @$this->db->query($sql); + if(class_exists('mysqli')) + $result = @$this->db->query($sql); + else + $result = @mysql_query($sql,$this->db); if($this->debug) { $mesg = ''; - if($this->db->errno) + if(class_exists('mysqli') && $this->db->errno) logger('dba: ' . $this->db->error); + else + logger('dba: ' . mysql_error($this->db)); if($result === false) $mesg = 'false'; |