From 65e28bc678b1d9fc0b6af4cb848cfde338b2f01c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 11 Jan 2009 23:08:23 +0000 Subject: Moving slowly forward on the batch installer. It now connects to the database and checks that the supplied database is defined. --- installer/libraries/Install_Mysql_Driver.php | 44 +++++++++++++++++++++++ installer/libraries/Install_Mysqli_Driver.php | 50 +++++++++++++++++++++++++++ installer/libraries/Mysql_Driver.php | 44 +++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 installer/libraries/Install_Mysql_Driver.php create mode 100644 installer/libraries/Install_Mysqli_Driver.php create mode 100644 installer/libraries/Mysql_Driver.php (limited to 'installer/libraries') diff --git a/installer/libraries/Install_Mysql_Driver.php b/installer/libraries/Install_Mysql_Driver.php new file mode 100644 index 00000000..ae44e040 --- /dev/null +++ b/installer/libraries/Install_Mysql_Driver.php @@ -0,0 +1,44 @@ +link = @mysql_connect($server, $user, $password); + if (!$this->link) { + throw new Exception(mysql_error()); + } + } + + public function __destruct() { + if (!empty($this->link)) { + @mysql_close($this->link); + } + } + + public function list_dbs() { + $db_list = mysql_list_dbs($this->link); + $databases = array(); + while ($row = mysql_fetch_object($db_list)) { + $databases[$row->Database] = 1; + } + return $databases; + } +} diff --git a/installer/libraries/Install_Mysqli_Driver.php b/installer/libraries/Install_Mysqli_Driver.php new file mode 100644 index 00000000..114a42f4 --- /dev/null +++ b/installer/libraries/Install_Mysqli_Driver.php @@ -0,0 +1,50 @@ +mysqli = @mysqli_connect($server, $user, $password); + if (!$this->mysqli) { + throw new Exception(mysqli_connect_error()); + } + } + + public function __destruct() { + if (!empty($this->mysqli)) { + @$this->mysqli->close(); + $this->mysqli = null; + } + } + + public function list_dbs() { + $db_list = $this->mysqli->query("SHOW DATABASES"); + $databases = array(); + if ($db_list) { + while ($row = $db_list->fetch_row()) { + $databases[$row[0]] = 1; + } + } + return $databases; + } +} + diff --git a/installer/libraries/Mysql_Driver.php b/installer/libraries/Mysql_Driver.php new file mode 100644 index 00000000..81848374 --- /dev/null +++ b/installer/libraries/Mysql_Driver.php @@ -0,0 +1,44 @@ +link = @mysql_connect($server, $user, $password); + if (!$this->link) { + throw new Exception(mysql_error()); + } + } + + public function __destruct() { + if (!empty($this->link)) { + @mysql_close($this->link); + } + } + + public function list_dbs() { + $db_list = mysql_list_dbs($this->link); + $databases = array(); + while ($row = mysql_fetch_object($db_list)) { + $databases[$row->Database] = 1; + } + return $databases; + } +} -- cgit v1.2.3