Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-159

Symfony Doctrine Task "doctrine:database:create" fails with "Undefined index: dbname"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major 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 -------------

        Activity

        Hide
        Ed Anderson added a comment -

        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.

        Show
        Ed Anderson added a comment - 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.
        Hide
        Guilherme Blanco added a comment -

        Formatted ticket

        Show
        Guilherme Blanco added a comment - Formatted ticket
        Hide
        Benjamin Eberlei added a comment -

        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.

        Show
        Benjamin Eberlei added a comment - 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.
        Hide
        Benjamin Eberlei added a comment -

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

        Show
        Benjamin Eberlei added a comment - The parameter name has to be "dbname" in symfony also.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Ed Anderson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: