Can't connect YII2 to oracle 11g


Can someone help me. I hv success developed a simple demo system using Yii2 and Mysql.

The problem happen when i try convert my database mysql to oracle.

This is several configuration involved:

  1. php.ini




  1. Success when test with php and oracle


header('Access-Control-Allow-Origin: *');

$tns = "



      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))



      (SERVICE_NAME = xe)




try {

    $conn = new PDO("oci:dbname=".$tns, 'demoyii2', 'pwd');


	echo 'SUCCESS: ';

} catch(PDOException $e) {

    echo 'ERROR: ' . $e->getMessage();



  1. db.php

return [

    'class' => 'yii\db\Connection',    

    'dsn' => 'oci:dbname=//localhost:1521/xe', // Oracle

    'username' => 'demoyii2',

    'password' => 'pwd',

    'charset' => 'utf8',


  1. Use dektrium/yii2-user

  2. When convert database mysql (table user) to oracle (become table user_). I rename it user_ to "user" in oracle

When try open the system, this error happen : The table does not exist: {{%user}} exists.

I try edit table name in


but still have an error.

public static function tableName()


    //return '{{%user}}'; 

    return "user";		


Anyone help?

Sorry my mistake, it solve

Problem with Case Sensitivity in oracle when create a table.


   (	"id" NUMBER(10,0), 

	"username" VARCHAR2(25 CHAR), 

	"email" VARCHAR2(255 CHAR), 

	"password_hash" VARCHAR2(60 CHAR), 

	"auth_key" VARCHAR2(32 CHAR), 


1 Like