Hello,
I use Oracle 11g and the tables in this DB are in UPPER CASE. For that I have a compatibility problem when I use YII2 advanced template. It does not recognize the name of the table and I get this error:
Database Exception – yii\db\Exception
SQLSTATE[HY000]: General error: 942 OCIStmtExecute: ORA-00942: Table ou vue inexistante
(ext\pdo_oci\oci_statement.c:148)
The SQL being executed was: SELECT COUNT(*) FROM "ville"
Error Info: Array
(
[0] => HY000
[1] => 942
[2] => OCIStmtExecute: ORA-00942: Table ou vue inexistante
(ext\pdo_oci\oci_statement.c:148)
)
↵
Caused by: PDOException
SQLSTATE[HY000]: General error: 942 OCIStmtExecute: ORA-00942: Table ou vue inexistante
(ext\pdo_oci\oci_statement.c:148)
in C:\wamp\www\Yii2Immo\advanced\vendor\yiisoft\yii2\db\Command.php at line 825
Can anyone help me plz.
Bizley
(Bizley)
June 26, 2015, 10:53am
2
Do you use it with active record? If so do you set the table name manually or leave it for Yii?
If the latter is true set this method in active record model:
public static function tableName()
{
return '{{%VILLE}}'; // or just 'VILLE'
}
Now when I want to generate model using gii, i get this error:
PHP Notice – yii\base\ErrorException
Trying to get property of non-object
Bizley
(Bizley)
June 26, 2015, 11:35am
5
Gii cannot handle uppercased table names? Sounds weird. Give us some more details about this error.
I have a table called ‘BIEN’ in my oracle DB. I want to generate a model for it. I get this error:
6593
Capture.PNG
Bizley
(Bizley)
June 26, 2015, 11:51am
7
See this https://github.com/yiisoft/yii2/issues/7757
Make sure your Yii version is 2.0.4. If it is and you’ve got the same problem add:
'attributes' => [
PDO::ATTR_CASE => PDO::CASE_LOWER,
],
in db connection settings and remove tableName() method.
I have 2.0.4 Yii version, then when I add this attributes configuration I get this problem:
6594
Capture.PNG
Bizley
(Bizley)
June 26, 2015, 12:09pm
9
You have not added it properly in config. Should go inside components > db
I am using YII2 advanced template. So i have put this conf on this path:
advanced/common/config/main-local.php
Is it right ?
I did, then I get this error:
6595
Capture.PNG
It does not work then I get again the problem of not recognizing the table name when I try to excute a query on an existed table:
6596
Capture.PNG
Bizley
(Bizley)
June 26, 2015, 1:30pm
14
I’m not 100% sure but it looks like you have not applied this configuration to the db connection you are using.
This is my DB configuration:
6600
Capture.PNG
Bizley
(Bizley)
June 26, 2015, 4:15pm
16
The question is if your current db connection is using this config. Is this the only configuration file for database?
Yes that the only configuration that I’m using. For the case sensitivity I have made my tables and my attributes in lower case by using the double quote. So for exemple, on my sql developper I transformed TABLE to “table”, and it workes.