From 9d564913f6ea913a39fe2e4937dc4703452c769d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 23 Apr 2013 04:52:03 -0700 Subject: dba driver cleanup --- include/dba/dba_driver.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'include/dba/dba_driver.php') diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index cdc79e9a1..1091b9632 100644 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -11,7 +11,6 @@ function dba_factory($server,$user,$pass,$db,$install = false) { require_once('include/dba/dba_mysql.php'); $dba = new dba_mysql($server,$user,$pass,$db,$install); } - $dba->connect($server,$user,$pass,$db); return $dba; } @@ -20,7 +19,6 @@ function dba_factory($server,$user,$pass,$db,$install = false) { abstract class dba_driver { protected $debug = 0; - protected $driver; protected $db; public $connected = false; public $error = false; @@ -31,22 +29,18 @@ abstract class dba_driver { abstract function close(); function __construct($server,$user,$pass,$db,$install = false) { - if($install) - $this->install($server,$user,$pass,$db); + if(($install) && (! $this->install($server,$user,$pass,$db))) { + return; + } $this->connect($server,$user,$pass,$db); } function install($server,$user,$pass,$db) { - $server = trim($server); - $user = trim($user); - $pass = trim($pass); - $db = trim($db); - if (!(strlen($server) && strlen($user))){ $this->connected = false; $this->db = null; - return; + return false; } if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) { @@ -54,15 +48,15 @@ abstract class dba_driver { $this->error = sprintf( t('Cannot locate DNS info for database server \'%s\''), $server); $this->connected = false; $this->db = null; - return; + return false; } } } - function dbg($dbg) { - $this->debug = $dbg; - } + function dbg($dbg) { + $this->debug = $dbg; + } function __destruct() { if($this->db && $this->connected) { -- cgit v1.2.3