From 3ce88a07d90464634ebc310e3f29a859bc28151d Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Tue, 8 Jan 2008 02:14:05 +0000 Subject: [PATCH] Merged revisions 47698 via svnmerge from svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/events ........ r47698 | sminnee | 2008-01-08 12:11:08 +1300 (Tue, 08 Jan 2008) | 1 line PDODatabase got the wrong end of the stick - Database::createDatabase() shouldn't need any arguments. Fixed this in the core class and MySQLDatabase, but PDODatabse still needs fixing. ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47710 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Database.php | 10 +++++----- core/model/MySQLDatabase.php | 2 +- core/model/PDODatabase.php | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/model/Database.php b/core/model/Database.php index 4547df587..3634280eb 100755 --- a/core/model/Database.php +++ b/core/model/Database.php @@ -49,13 +49,13 @@ abstract class Database extends Object { * Create the database and connect to it. This can be called if the * initial database connection is not successful because the database * does not exist. - * @param string $connect Connection string - * @param string $username Database username - * @param string $password Database Password - * @param string $database Database to which to create + * + * It takes no parameters, and should create the database from the information + * specified in the constructor. + * * @return boolean Returns true if successful */ - abstract function createDatabase($connect, $username, $password, $database); + abstract function createDatabase(); /** * Build the connection string from input diff --git a/core/model/MySQLDatabase.php b/core/model/MySQLDatabase.php index d025a49dc..7e522adbb 100644 --- a/core/model/MySQLDatabase.php +++ b/core/model/MySQLDatabase.php @@ -127,7 +127,7 @@ class MySQLDatabase extends Database { return $this->active ? true : false; } - public function createDatabase($connect, $username, $password, $db) { + public function createDatabase() { $this->query("CREATE DATABASE $this->database"); $this->query("USE $this->database"); diff --git a/core/model/PDODatabase.php b/core/model/PDODatabase.php index 369a19b2c..dc8d0fd84 100644 --- a/core/model/PDODatabase.php +++ b/core/model/PDODatabase.php @@ -58,6 +58,7 @@ class PDODatabase extends Database { try { // Try connect to the database, if it does not exist, create it $this->dbConn = new PDO($connectWithDB, $parameters['username'], $parameters['password']); } catch (PDOException $e) { + // To do - this is an instance method, not a static method. Call it as such. if (!self::createDatabase($connect, $parameters['username'], $parameters['password'], $parameters['database'])) { $this->databaseError("Could not connect to the database, make sure the server is available and user credentials are correct"); } else { @@ -228,6 +229,7 @@ class PDODatabase extends Database { * @param string $password Database Password * @param string $database Database to which to create * @return boolean Returns true if successful + * @todo This shouldn't take any arguments; it should take the information given in the constructor instead. */ public function createDatabase($connect, $username, $password, $database) { try { @@ -713,4 +715,4 @@ class PDOQuery extends Query { } -?> +?>