Can't connect YII2 to oracle 11g

Hello…

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



;extension=php_oci8.dll

extension=php_oci8_11g.dll 

extension=php_pdo_mysql.dll



  1. Success when test with php and oracle



<?php

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

$tns = "

(DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME = xe)

    )

  )

       ";

try {

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

    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

	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


vendor/dektrium/yii2-user/models/User.php

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.




CREATE TABLE "DEMOYII2"."user" 

   (	"id" NUMBER(10,0), 

	"username" VARCHAR2(25 CHAR), 

	"email" VARCHAR2(255 CHAR), 

	"password_hash" VARCHAR2(60 CHAR), 

	"auth_key" VARCHAR2(32 CHAR), 

        ...



1 Like