mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-29 20:59:23 +02:00
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
This commit is contained in:
parent
5606e9278b
commit
3ce88a07d9
@ -49,13 +49,13 @@ abstract class Database extends Object {
|
|||||||
* Create the database and connect to it. This can be called if the
|
* Create the database and connect to it. This can be called if the
|
||||||
* initial database connection is not successful because the database
|
* initial database connection is not successful because the database
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @param string $connect Connection string
|
*
|
||||||
* @param string $username Database username
|
* It takes no parameters, and should create the database from the information
|
||||||
* @param string $password Database Password
|
* specified in the constructor.
|
||||||
* @param string $database Database to which to create
|
*
|
||||||
* @return boolean Returns true if successful
|
* @return boolean Returns true if successful
|
||||||
*/
|
*/
|
||||||
abstract function createDatabase($connect, $username, $password, $database);
|
abstract function createDatabase();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the connection string from input
|
* Build the connection string from input
|
||||||
|
@ -127,7 +127,7 @@ class MySQLDatabase extends Database {
|
|||||||
return $this->active ? true : false;
|
return $this->active ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createDatabase($connect, $username, $password, $db) {
|
public function createDatabase() {
|
||||||
$this->query("CREATE DATABASE $this->database");
|
$this->query("CREATE DATABASE $this->database");
|
||||||
$this->query("USE $this->database");
|
$this->query("USE $this->database");
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ class PDODatabase extends Database {
|
|||||||
try { // Try connect to the database, if it does not exist, create it
|
try { // Try connect to the database, if it does not exist, create it
|
||||||
$this->dbConn = new PDO($connectWithDB, $parameters['username'], $parameters['password']);
|
$this->dbConn = new PDO($connectWithDB, $parameters['username'], $parameters['password']);
|
||||||
} catch (PDOException $e) {
|
} 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'])) {
|
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");
|
$this->databaseError("Could not connect to the database, make sure the server is available and user credentials are correct");
|
||||||
} else {
|
} else {
|
||||||
@ -228,6 +229,7 @@ class PDODatabase extends Database {
|
|||||||
* @param string $password Database Password
|
* @param string $password Database Password
|
||||||
* @param string $database Database to which to create
|
* @param string $database Database to which to create
|
||||||
* @return boolean Returns true if successful
|
* @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) {
|
public function createDatabase($connect, $username, $password, $database) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user