Skip to content


DBAL-159: Symfony Doctrine Task "doctrine:database:create" fails with "Undefined index: dbname" #1315

doctrinebot opened this Issue · 5 comments

2 participants


Jira issue originally created by user digitalmechanic:

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)(*NAME=pmdb0)));charset=UTF8';
$user = 'pmcore';
$pass = 'mypaswd';

    $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 -------------


Comment created by digitalmechanic:

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.


Comment created by @guilhermeblanco:

Formatted ticket


Comment created by @beberlei:

I would advise against using the PDO Oracle driver, as PDO Oracle has bugs and it is not maintained anymore, not even by Oracle. OCI8 is the way to go.

Also creating a database is not supported in Oracle, since there is no concept database.


Comment created by @beberlei:

The parameter name has to be "dbname" in symfony also.


Issue was closed with resolution "Invalid"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.