make sure db queries never get called if the database isn't open

This commit is contained in:
Friendika 2011-03-03 15:41:08 -08:00
parent bfdf4bddc9
commit b8757fb456
2 changed files with 11 additions and 8 deletions

View File

@ -3,7 +3,7 @@
set_time_limit(0); set_time_limit(0);
define ( 'BUILD_ID', 1039 ); define ( 'BUILD_ID', 1039 );
define ( 'FRIENDIKA_VERSION', '2.10.0908' ); define ( 'FRIENDIKA_VERSION', '2.10.0909' );
define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );

View File

@ -20,12 +20,14 @@ class dba {
function __construct($server,$user,$pass,$db,$install = false) { function __construct($server,$user,$pass,$db,$install = false) {
$this->db = @new mysqli($server,$user,$pass,$db); $this->db = @new mysqli($server,$user,$pass,$db);
if((mysqli_connect_errno()) && (! $install)) { if(! mysql_connect_errno()) {
$this->db = null; $this->connected = true;
system_unavailable(); }
else {
$this->db = null;
if(! $install)
system_unavailable();
} }
else
$this->connected = true;
} }
public function getdb() { public function getdb() {
@ -34,7 +36,7 @@ class dba {
public function q($sql) { public function q($sql) {
if(! $this->db ) if((! $this->db) || (! $this->connected))
return false; return false;
$result = @$this->db->query($sql); $result = @$this->db->query($sql);
@ -92,7 +94,8 @@ class dba {
} }
public function escape($str) { public function escape($str) {
return @$this->db->real_escape_string($str); if($this->db && $this->connected)
return @$this->db->real_escape_string($str);
} }
function __destruct() { function __destruct() {