[2.0] Small cleanups
This commit is contained in:
parent
2a9886af48
commit
8de151d8ea
@ -115,7 +115,7 @@ class Connection
|
||||
* @var integer
|
||||
*/
|
||||
protected $_transactionNestingLevel = 0;
|
||||
|
||||
|
||||
/**
|
||||
* The currently active transaction isolation level.
|
||||
*
|
||||
@ -193,7 +193,7 @@ class Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of parameters used to instantiated this connection instance
|
||||
* Gets the parameters used during instantiation.
|
||||
*
|
||||
* @return array $params
|
||||
*/
|
||||
@ -203,7 +203,7 @@ class Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the database connected to for this Connection instance
|
||||
* Gets the name of the database this Connection is connected to.
|
||||
*
|
||||
* @return string $database
|
||||
*/
|
||||
@ -262,18 +262,12 @@ class Connection
|
||||
if ($this->_isConnected) return false;
|
||||
|
||||
$driverOptions = isset($this->_params['driverOptions']) ?
|
||||
$this->_params['driverOptions'] : array();
|
||||
$user = isset($this->_params['user']) ?
|
||||
$this->_params['user'] : null;
|
||||
$this->_params['driverOptions'] : array();
|
||||
$user = isset($this->_params['user']) ? $this->_params['user'] : null;
|
||||
$password = isset($this->_params['password']) ?
|
||||
$this->_params['password'] : null;
|
||||
$this->_params['password'] : null;
|
||||
|
||||
$this->_conn = $this->_driver->connect(
|
||||
$this->_params,
|
||||
$user,
|
||||
$password,
|
||||
$driverOptions
|
||||
);
|
||||
$this->_conn = $this->_driver->connect($this->_params, $user, $password, $driverOptions);
|
||||
|
||||
$this->_isConnected = true;
|
||||
|
||||
|
@ -11,6 +11,11 @@ use Doctrine\DBAL\Platforms;
|
||||
*/
|
||||
class Driver implements \Doctrine\DBAL\Driver
|
||||
{
|
||||
/**
|
||||
* Attempts to connect to the database and returns a driver connection on success.
|
||||
*
|
||||
* @return Doctrine\DBAL\Driver\Connection
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
|
||||
{
|
||||
return new \Doctrine\DBAL\Driver\PDOConnection(
|
||||
@ -24,7 +29,7 @@ class Driver implements \Doctrine\DBAL\Driver
|
||||
/**
|
||||
* Constructs the Postgres PDO DSN.
|
||||
*
|
||||
* @return string The DSN.
|
||||
* @return string The DSN.
|
||||
*/
|
||||
private function _constructPdoDsn(array $params)
|
||||
{
|
||||
|
@ -879,6 +879,7 @@ abstract class AbstractSchemaManager
|
||||
try {
|
||||
return call_user_func_array(array($this, $method), $args);
|
||||
} catch (\Exception $e) {
|
||||
//var_dump($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -189,12 +189,8 @@ class OracleSchemaManager extends AbstractSchemaManager
|
||||
$query = 'CREATE USER ' . $username . ' IDENTIFIED BY ' . $password;
|
||||
$result = $this->_conn->exec($query);
|
||||
|
||||
try {
|
||||
$query = 'GRANT CREATE SESSION, CREATE TABLE, UNLIMITED TABLESPACE, CREATE SEQUENCE, CREATE TRIGGER TO ' . $username;
|
||||
$result = $this->_conn->exec($query);
|
||||
} catch (Exception $e) {
|
||||
$this->dropDatabase($database);
|
||||
}
|
||||
$query = 'GRANT CREATE SESSION, CREATE TABLE, UNLIMITED TABLESPACE, CREATE SEQUENCE, CREATE TRIGGER TO ' . $username;
|
||||
$result = $this->_conn->exec($query);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.phpdoctrine.org>.
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Schema;
|
||||
@ -264,4 +264,26 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
|
||||
|
||||
return array_merge($decl, $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops a database.
|
||||
* If no database name is given, then the database this SchemaManager is
|
||||
* currently connected to is dropped. In order to do this, the connection is
|
||||
* closed and reopened on the "template1" database.
|
||||
*
|
||||
* @param string $database The name of the database to drop.
|
||||
* @return boolean $result
|
||||
*/
|
||||
public function dropDatabase($database = null)
|
||||
{
|
||||
if (is_null($database)) {
|
||||
$database = $this->_conn->getDatabase();
|
||||
}
|
||||
$sql = $this->_platform->getDropDatabaseSql($database);
|
||||
|
||||
//$this->_conn->close();
|
||||
|
||||
|
||||
return $this->_executeSql($sql, 'execute');
|
||||
}
|
||||
}
|
@ -107,11 +107,11 @@ class OrmFunctionalTestCase extends OrmTestCase
|
||||
}
|
||||
}
|
||||
if ($classes) {
|
||||
try {
|
||||
//try {
|
||||
$this->_schemaTool->createSchema($classes);
|
||||
} catch (\Exception $e) {
|
||||
//} catch (\Exception $e) {
|
||||
// Swallow all exceptions. We do not test the schema tool here.
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,34 @@
|
||||
|
||||
namespace Doctrine\Tests;
|
||||
|
||||
/**
|
||||
* TestUtil is a class with static utility methods used during tests.
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class TestUtil
|
||||
{
|
||||
/**
|
||||
* Gets a <b>real</b> database connection using the following parameters
|
||||
* of the $GLOBALS array:
|
||||
*
|
||||
* 'db_type' : The name of the Doctrine DBAL database driver to use.
|
||||
* 'db_username' : The username to use for connecting.
|
||||
* 'db_password' : The password to use for connecting.
|
||||
* 'db_host' : The hostname of the database to connect to.
|
||||
* 'db_name' : The name of the database to connect to.
|
||||
* 'db_port' : The port of the database to connect to.
|
||||
*
|
||||
* Usually these variables of the $GLOBALS array are filled by PHPUnit based
|
||||
* on an XML configuration file. If no such parameters exist, an SQLite
|
||||
* in-memory database is used.
|
||||
*
|
||||
* IMPORTANT:
|
||||
* 1) Each invocation of this method returns a NEW database connection.
|
||||
* 2) The database is dropped and recreated to ensure it's clean.
|
||||
*
|
||||
* @return Doctrine\DBAL\Connection The database connection instance.
|
||||
*/
|
||||
public static function getConnection()
|
||||
{
|
||||
if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user