Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCI8Connection: incomplete recognition of the configuration ? #38

Closed
apricotpoodle opened this issue Apr 15, 2019 · 2 comments
Closed

Comments

@apricotpoodle
Copy link

DataSource configuration, in config\app.php, is NOT 100% recognized,
especially options like charset, persistent, etc…

Option charset is not recognized in this function :
https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Database/OCI8/OCI8Connection.php#L55-59

because in file:
https://github.com/CakeDC/cakephp-oracle-driver/blob/master/src/Database/Driver/OracleOCI.php#L20-30

There seems to be a typo.

protected function _connect($dsn, array $config)
{
//why only config[flags] and not all config from DataSource in App.php ?
//$connection = new OCI8Connection($dsn, $config['username'], $config['password'], $config['flags']);

//SHOULD IT BE ?
$connection = new OCI8Connection($dsn, $config['username'], $config['password'], $config);

// now works fine for me and charset option is now recognized.
// Solved my problem of charset conversion.

    $this->setconnection($connection);
    return true;
}

Anyway thanks for making the plugin by the way, works great !

@jmbIFR
Copy link

jmbIFR commented Apr 15, 2019

You are right, the cakephp-oracle-driver plugin need more documentation on configs options.

For using the cakephp-oracle-driver without modifing the code, you can use the flags and init options in your config file.

Below an personnal example of cakephp-oracle-driver config in config/app.php

the use of, ['flags'=>'charset'], ['flags=>'persistent'] or ['init'] is not documented

'default' => [
   'className' => 'CakeDC\OracleDriver\Database\OracleConnection',
   'driver' => 'CakeDC\OracleDriver\Database\Driver\OracleOCI', # For OCI8
   'host' => '', # Database host name or IP address or blank for complexe oracle database entry defined in database option
   'port' => '', # Database port number (default: 1521)
   'username' => 'user1',          # Database username
   'password' => 'password',       # Database password
   'database' => '(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=server1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=server1)(PORT=1521)) )(CONNECT_DATA=(SERVICE_NAME=INSTX_TAF)(INSTANCE_NAME=INSTX)(GLOBAL_NAME=INSTD)))',
   'flags'=> [
       'charset'=>'al32utf8',
       'persistent'=>true
   ],
   'init'=>["ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '.,'"]

@apricotpoodle
Copy link
Author

Thank you very much for the clearness and conciseness of your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants