2008-09-12 12:51:56 +04:00
|
|
|
<?php
|
|
|
|
|
2009-01-03 22:50:13 +03:00
|
|
|
#namespace Doctrine\DBAL\Driver\PDOMySql;
|
2008-09-12 12:51:56 +04:00
|
|
|
|
2009-01-03 22:50:13 +03:00
|
|
|
#use Doctrine\DBAL\Driver;
|
2008-09-12 12:51:56 +04:00
|
|
|
|
|
|
|
class Doctrine_DBAL_Driver_PDOMySql_Driver implements Doctrine_DBAL_Driver
|
|
|
|
{
|
|
|
|
|
|
|
|
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
|
|
|
|
{
|
2008-09-12 21:25:38 +04:00
|
|
|
return new Doctrine_DBAL_Driver_PDOConnection(
|
|
|
|
$this->_constructPdoDsn($params),
|
|
|
|
$username,
|
|
|
|
$password,
|
|
|
|
$driverOptions);
|
2008-09-12 12:51:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs the MySql PDO DSN.
|
|
|
|
*
|
|
|
|
* Overrides Connection#_constructPdoDsn().
|
|
|
|
*
|
|
|
|
* @return string The DSN.
|
|
|
|
*/
|
|
|
|
private function _constructPdoDsn(array $params)
|
|
|
|
{
|
|
|
|
$dsn = 'mysql:';
|
|
|
|
if (isset($params['host'])) {
|
|
|
|
$dsn .= 'host=' . $params['host'] . ';';
|
|
|
|
}
|
|
|
|
if (isset($params['port'])) {
|
|
|
|
$dsn .= 'port=' . $params['port'] . ';';
|
|
|
|
}
|
|
|
|
if (isset($params['dbname'])) {
|
|
|
|
$dsn .= 'dbname=' . $params['dbname'] . ';';
|
|
|
|
}
|
|
|
|
if (isset($params['unix_socket'])) {
|
|
|
|
$dsn .= 'unix_socket=' . $params['unix_socket'] . ';';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $dsn;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDatabasePlatform()
|
|
|
|
{
|
|
|
|
return new Doctrine_DatabasePlatform_MySqlPlatform();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSchemaManager(Doctrine_Connection $conn)
|
|
|
|
{
|
|
|
|
return new Doctrine_Schema_MySqlSchemaManager($conn);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|