Yii的Gii生成Oracle的modal时候出错

Yii的Gii生成Oracle的modal时候出错

先说一下,本文提到的问题涉及的环境:

  1. Linux Centos 7
  2. Oracle 12c
  3. Yii 2.0.8
  4. httpd

 

使用Yii的Gii生成modal的时候遇到下面的错误

Database Exception – yii\db\Exception
ORA-00942: table or view does not exist
The SQL being executed was: SELECT username
FROM dba_users u
WHERE EXISTS (
SELECT 1
FROM dba_objects o
WHERE o.owner = u.username )
AND default_tablespace not in ('SYSTEM','SYSAUX')

Caused by: PDOException
ORA-00942: table or view does not exist

 

如果Yii的版本是2.0.4,那么你还需要在config/db.php添加下面蓝色的部分

 10 return [
 11     'class' => '\sfedosimov\oci8pdo\Oci8PDO_Connection',
 12     'dsn' => 'oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.x)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl.localdomain)));charset=AL32UTF8;',
 13     'username' => 'name',
 14     'password' => 'xxxx',
 15     'charset' => 'utf8',

 16     'attributes' => [
 17         PDO::ATTR_CASE=>PDO::CASE_LOWER,
 18         ],

 19 ];

这算是2.0.4的bug,关于这个bug请参看官网

https://github.com/yiisoft/yii2/issues/7757

由于我用的是2.0.8这个问题已经修复,所以不是这个问题导致,而是由于缺少DBA的权限,所以登录oracle服务器,然后使用sysdba链接数据库

$> sqlplus "/ as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 2 02:01:50 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

接下来赋予DBA权限,xxxx替换成你的用户名

SQL> GRANT DBA to xxxx;

 

i

 

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章转载自:IT夜班车,否则按侵权处理i.

    分享到:

Leave a Reply

Your email address will not be published. Required fields are marked *