Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: 2.1
-
Fix Version/s: None
-
Component/s: Drivers
-
Labels:None
-
Environment:Symfony 2.0, Doctrine 2.1, PHP 5.3.8 and Oracle 11g-R2 Enterprise
Description
For some reason,when attempting to create a database, the doctrine:database:create task fails complaining that the "dbname" parameter is not found. Printing the $params var from the file "vendor/doctrine-dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php" indeed shows that the dbname array element is not present. However, it is present in the app/config/parameters.ini (as database_name).
The following is the method from PDOOracle/Driver.php where the missing "dbname" index is used a few times... adding the dbname with an appropriate value
allows the dsn to get created - but Oracle then throws an ORA-00911 error indicating an invalid character in the PDO statement... However, I'm able to use the output of _constructPdoDsn( ) in a simple standalone connect script (provided below) successfully.
private function _constructPdoDsn(array $params) { $params['dbname'] = 'pmdb0'; // Inserted for testing by Ed Anderson $dsn = 'oci:'; if (isset($params['host'])) { $dsn .= 'dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' . '(HOST=' . $params['host'] . ')'; if (isset($params['port'])) { $dsn .= '(PORT=' . $params['port'] . ')'; } else { $dsn .= '(PORT=1521)'; } $dsn .= '))(CONNECT_DATA=(SERVICE_NAME=' . $params['dbname'] . ')))'; } else { $dsn .= 'dbname=' . $params['dbname']; } if (isset($params['charset'])) { $dsn .= ';charset=' . $params['charset']; } print( $dsn ); // Inserted to extract the constructed DSN and test in an external php script... return $dsn; }
-------- Script created using the output of _constructPdoDsn( ) follows ----- This script works fine...
$dsn = 'oci:dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=pmdb0.mydomain.net)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=pmdb0)));charset=UTF8'; $user = 'pmcore'; $pass = 'mypaswd'; try { $dbh = new PDO( $dsn, $user, $pass ); if( $dbh ) { print( "Connected to PDO using: " . $dsn . "\n"); unset( $dbh ); } } catch( PDOException $e ) { print( "ERROR: " . $e->getMessage( ) ); die( ); }
---------------- End Test Script -------------
Running the task doctrine:schema:create --dump-sql produces output that will correctly build the tables in the database manually... but this is not ideal obviously. Still can't seem to find where the "invalid character" is showing in the statement generated by the PDOOracle Driver or some other file in the DBAL.