简体   繁体   中英

Database Exception with Gii Generator on Yii2

First of all, my details(I try to include as much as I can):

PHP 5.6.14

Oracle DB11G Enterprise Edition 11.2.0.1.0(Installed locally, default localhost setup)

Windows 7 64-Bit

Oci8-2.0.8-5.6-ts-vc11-x86

Yii 2.0.6

I am trying to use the gii module to generate some models for testing purpose(as I am fairly new to this framework). I have imported all the tables/data from my organization's database, and have create related tablespaces and users. So my generator have these autocompleted when i typed partial keywords.

在此输入图像描述

Then when I clicked on preview button, i get this error below

在此输入图像描述

I believe the SYSTEM/SYSAUX are generated automatically when installing the oracle db. Plus, the autocomplete tables that appeared when I try to insert the table name is correct and same as the tables i have inside our schema. I tried changing the password/creds to be wrong as I cant access the gii page at all(so i believe the connection to my db setup is fine).

Can anyone help me. is it a known issue or i am doing something wrong? because as far as I understand, the error shown means that the generator is looking at a different place upon clicking the "preview" button.

Thank you.

**

UPDATE: New error

**

I gave the current user the role of DBA and now it's getting somewhere but I do not understand the cause/errors.

在此输入图像描述

ORA-00942: table or view does not exist

Looking at the failing SQL, it seems the user which is executing the query doesn't have the DBA privilege to access dba_users and dba_objects . You need to GRANT the required privilege to this user.

GRANT DBA to new_user;

I have figured this out. Since my databases and tables are pretty huge, I need to uncheck the "Generate with relations" checkbox.

Everything is now working fine. I am now able to fully utilize the Gii goodness!

Anyway I still chose Lalit Kumar's answer since that really helps a lot as it is something that I can't even imagine, thinking it was not something related to the DB. Turns out it is!

the second error about relations generation is a bug about Yii2, and now have been fixed.

Ref: Fixes #166: Fixed "Trying to get property of non-object" during model…

https://github.com/yiisoft/yii2-gii/commit/45696e9f01485799022b0daa56372fc00baece06

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM