Latest news:

Sahih al-Bukhari (সহীহ বুখারী) is a free Hadith application for android. This application is advertisement free. Download now

Yii oracle database connection in windows

Yii oracle database connection in windows

In this post we will learn how to connect oracle database using PHP Yii framework.

Following steps we need to follow to accomplish this

  • Enable php_oci8.dll extension
  • Restart the apache server
  • Add connection string
  • DB username
  • DB Password
  • Adding charset(optional)

At first we need to enable php_oci8.dll extension. This extension is used to connect our application to Oracle Database.

We can do this by openning php.ini file in any code editor and find ;extension=php_oci8.dll

we have to remove (;) to enable this extension from left side for example 

;extension=php_oci8.dll to extension=php_oci8.dll

After removing the ; semicolon we have to restart the apache server.

In our application now open main.php file under yourproject/protected/config/main.php file,

search for db = array() section and add the following code

connectionString : oci:dbname=;charset=AL32UTF8

username : dbUsername

password : dbPassword

In the connection string OCI is php api to connect oracle DB. dbname contains server IP address and port number.

XE is Database edition, in my case its Express Edition.

charset is character encoding for database table.

Below code is the example of database connection for oracle in yii application

'db' => array(
            'connectionString' => 'oci:dbname=;charset=AL32UTF8',
            'username' => 'pos',
            'password' => 'pos',
Tags : Oracle, PHP, Yii,

Views : 936

Subscribe Us

Follow Us