Oracle DB Base Component
Base library and foundation components for Oracle Database, (*1)
Why Using this Package?
Not all developer has access to Oracle DB as SYSDBA role., (*2)
In the default yii\db\oci\Schema
, the database connection must specify user which has access to DBA_USERS
view., (*3)
Please refer to findSchemaNames()
function in :
https://github.com/yiisoft/yii2/blob/master/framework/db/oci/Schema.php
, (*4)
Installation
The preferred way to install this extension is through composer., (*5)
Either run, (*6)
php composer.phar require --prefer-dist adipriyantobpn/yii2-db-oracle "*"
or add, (*7)
"adipriyantobpn/yii2-db-oracle": "*"
to the require section of your composer.json
file., (*8)
Usage
Once the extension is installed, you can access Oracle DB by configure db component in your config.php
like this:, (*9)
'components' => [
'db' => [
'class' => 'adipriyantobpn\db\oracle\Connection',
'host' => 'localhost',
'port' => 1522 // default: 1521
'sid' => 'XE'
'dateFormat' => 'DD-MON-RR' // default: 'YYYY-MM-DD HH24:MI:SS'
],
]
By using configuration format above, the connection class will be automatically build Oracle DSN by using this template:, (*10)
$this->dsn = "oci:dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={$this->host})(PORT={$this->port})))(CONNECT_DATA=(SID={$this->sid})))"
But if you want to configure DSN with different format, you can omit host, port, and sid properties like this:, (*11)
'components' => [
'db' => [
'class' => 'adipriyantobpn\db\oracle\Connection',
'dsn' => 'oci:dbname=//localhost:1521/XE',
'dateFormat' => 'DD-MON-RR' // default: 'YYYY-MM-DD HH24:MI:SS'
],
]