111,8 → 111,7 |
* @param string $dsn |
* @param string $username |
* @param string $password |
* @param array $options |
* @see PDO::__construct() |
* @param mixed $options |
*/ |
public function __construct ($dsn = '', $username = null, |
$password = null, array $options = array()) |
153,53 → 152,6 |
} |
|
/** |
* Creates a database according to the specified parameters |
* |
* Should be overwritten and called by inheriting classes. |
* |
* @param string $dsn |
* Connection DSN (required; must not include the database |
* name). |
* @param string $username = null |
* Connection username. The default is specified by the |
* <code>$_username</code> property. Note that creating |
* the database usually requires a user with more privileges |
* than the one accessing the database or its tables. |
* @param string $password = null |
* Connection password. The default is specified by the |
* <code>$_password</code> property. |
* @param array? $options = null |
* Connection options. The default is specified by the |
* <code>$_options</code> property. |
* @param string $spec = null |
* Additional database specifications, like character encoding |
* and collation. |
* @param boolean $force = false |
* If a true-value, the database will be attempted to be |
* created even if there is a database of the name specified |
* by the <code>$_dbname</code> property. |
* @return int |
* The number of rows affected by the CREATE DATABASE statement. |
* @see PDO::__construct() |
* @see PDO::exec() |
*/ |
public function create ($dsn, $username = null, $password = null, |
array $options = null, $dbspec = null, $force = false) |
{ |
$connection = new PDO($dsn, |
$username !== null ? $username : $this->_username, |
$password !== null ? $password : $this->_password, |
$options !== null ? $options : $this->_options); |
|
$query = 'CREATE DATABASE' |
. (!$force ? ' IF NOT EXISTS' : '') |
. ' ' . $this->escapeName($this->_dbname) |
. ($dbspec ? ' ' . $dbspec : ''); |
|
return $connection->exec($query); |
} |
|
/** |
* Initiates a transaction |
* |
* @return bool |