aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-03-01 16:24:22 -0800
committerFriendika <info@friendika.com>2011-03-01 16:24:22 -0800
commit5ff1462e1e98e97f623022c23deea0147c62327b (patch)
tree99f55035e9a3646e016a5f6239dd7245020284bb /include
parent2d4b3bee609e2d5aa9a421e6e9e9283b49f225db (diff)
downloadvolse-hubzilla-5ff1462e1e98e97f623022c23deea0147c62327b.tar.gz
volse-hubzilla-5ff1462e1e98e97f623022c23deea0147c62327b.tar.bz2
volse-hubzilla-5ff1462e1e98e97f623022c23deea0147c62327b.zip
install issue (memory exhausted) due to incorrect db open check
Diffstat (limited to 'include')
-rw-r--r--include/dba.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/include/dba.php b/include/dba.php
index e58abb1a1..d3da8eae0 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -16,11 +16,16 @@ class dba {
private $debug = 0;
private $db;
+ public $connected = false;
function __construct($server,$user,$pass,$db,$install = false) {
$this->db = @new mysqli($server,$user,$pass,$db);
- if((mysqli_connect_errno()) && (! $install))
- system_unavailable();
+ if((mysqli_connect_errno()) && (! $install)) {
+ $this->db = null;
+ system_unavailable();
+ }
+ else
+ $this->connected = true;
}
public function getdb() {
@@ -114,7 +119,7 @@ function dbg($state) {
if(! function_exists('dbesc')) {
function dbesc($str) {
global $db;
- if($db)
+ if($db->connected)
return($db->escape($str));
else
return(str_replace("'","\\'",$str));
@@ -133,7 +138,7 @@ function q($sql) {
$args = func_get_args();
unset($args[0]);
- if($db) {
+ if($db->connected) {
$ret = $db->q(vsprintf($sql,$args));
return $ret;
}
@@ -160,7 +165,10 @@ if(! function_exists('dbq')) {
function dbq($sql) {
global $db;
- $ret = $db->q($sql);
+ if($db->connected)
+ $ret = $db->q($sql);
+ else
+ $ret = false;
return $ret;
}}