Jonnny
Jonnny

Reputation: 5039

local XAMPP install connecting to live oracle DB DSN

I am using Yii2 locally on my PC, but wishing to connect to our production server DB I have tried the string:

'dbname=//host:port/servicename', but it says Connection does not support reading schema

I've never tried to connect Yii2 to oracle before or connect to a live DB. What is the way to achieve this if it is even possible?

I also read this link https://www.quora.com/How-do-I-connect-Yii-to-Oracle and changed mine to the format mentioned which was

 'db' => [ 
  'class' => '\yii\db\Connection',
  'dsn' => 'oci:dbname=SOME_IP_ADDRESS:PORT/YOUR_SID;charset=UTF8',
  'username' => 'your_username',
  'password' => 'your_password',
  'charset' => 'utf8',
], 

But I got the same error. Except I am using a service name in place of a SID

Update

Ok, looking at the Yii code

/**
 * Returns the schema information for the database opened by this connection.
 * @return Schema the schema information for the database opened by this connection.
 * @throws NotSupportedException if there is no support for the current driver type
 */
public function getSchema()
{
    if ($this->_schema !== null) {
        return $this->_schema;
    } else {
        $driver = $this->getDriverName();
        if (isset($this->schemaMap[$driver])) {
            $this->_schema = \Yii::createObject($this->schemaMap[$driver]);
            $this->_schema->db = $this;
            return $this->_schema;
        } else {
            throw new NotSupportedException("Connection does not support reading schema information for '$driver' DBMS.");
        }
    }
}

The driver isn't supported I think, so how do I found out which ones are?

Upvotes: 1

Views: 753

Answers (2)

Jonnny
Jonnny

Reputation: 5039

After some searching around into my set up. The following worked for me

config/db.php

return [
'class' => 'yii\db\Connection',
'dsn' => 'oci:dbname=IP_ADDRESS:PORT/DB_NAME', 
'username' => 'USERNAME',
'password' => 'PASSWORD',
'charset' => 'utf8',
];

I also had to uncomment in my php.ini file

extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client

I also had to download the OCI8 DLL Driver from PECL http://pecl.php.net/package/oci8/2.0.8/windows/

My XAMPP came with 12c but that failed to work with my set up.

Upvotes: 1

Everton Mendonça
Everton Mendonça

Reputation: 688

You need to install and enable PHP support for Oracle databases.

There's a detailed tutorial here.

Upvotes: 1

Related Questions