I'm trying to connect yii2-advanced project with oracle database, here is the 'db' component code inside common\main-local.php
.
'db' => [
'class' => 'CDbConnection',
'dsn' => 'oci:dbname=127.0.0.1:1521/xyz;charset=UTF8',
'username' => 'xyz',
'password' => 'xyz',
],
Now, if I use 'class' => "CDbConnection"
as a class, it shows following exception,
Not instantiable – yii\di\NotInstantiableException
Failed to instantiate component or class "CDbConnection".
↵ Caused by: ReflectionException
Class CDbConnection does not exist
in C:\xampp\htdocs\ramisha\advanced\vendor\yiisoft\yii2\di\Container.php at line 507
I have no idea why is it missing in my project. Also, if I use 'class' => 'yii\db\Connection'
, inside db
component it shows following error:
Database Exception – yii\db\Exception
SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12541: TNS:no listener
(ext\pdo_oci\oci_driver.c:714)
↵
Caused by: PDOException
SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12541: TNS:no listener
(ext\pdo_oci\oci_driver.c:714)
in C:\xampp\htdocs\ramisha\advanced\vendor\yiisoft\yii2\db\Connection.php at line 712
Which one is the correct class to be used for connecting oracle database to yii2 project with PDO?
- I have checked for listener.ora file, which is missing in the oracle folder's sub-directories, is it a necessary file?
- I have followed this guide to set instantclient_19_10 in oracle folder and set it as path variable in system environment.
- Followed one of the answers from this How to enable oci in xampp 5.6.3? to set PHP.INI and xampp configuration for oci driver
- "php -m" shows following the list [PHP Modules]
- bcmath
- calendar
- Core
- ctype
- curl
- date
- dom
- exif
- filter
- gd
- gettext
- hash
- iconv
- imap
- json
- libxml
- mbstring
- mysqli
- mysqlnd
- openssl
- pcre
- PDO
- pdo_mysql
- pdo_sqlite
- pdo_sqlsrv
- Phar
- readline
- Reflection
- session
- SimpleXML
- soap
- SPL
- sqlsrv
- standard
- tidy
- tokenizer
- wddx
- xml
- xmlreader
- xmlrpc
- xmlwriter
- zip
- zlib
Where exactly is the issue and what to do?