Laravel 5.4中的模型表名称较低 - 似乎只发生在“帐户”中?

时间:2017-06-22 06:14:55

标签: php oracle laravel-5.4

我正在使用Laravel 5.4连接到Oracle DB。

创建的表名为ACCOUNT(大写)。

我创建了名为Account的模型类,并设置:

protected $table = 'account';

当我使用此模型或表帐户执行任何查询时,表名被双引号并抛出QueryException:

QueryException in Connection.php line 647:
Error Code : 942
Error Message : ORA-00942: table or view does not exist
Position : 29
Statement : select * from (select * from "account" where "account"."ID" = :p0) where rownum = 1
Bindings : [123]
(SQL: select * from (select * from "account" where "account"."ID" = 123) where rownum = 1)

显然,Oracle将无法找到表“帐户”,因为只存在“帐户”。如果表名不是双引号(那么它不区分大小写)。

因此,当我将表名更改为account2时,表名会变为大写?

QueryException in Connection.php line 647:
Error Code : 942
Error Message : ORA-00942: table or view does not exist
Position : 29
Statement : select * from (select * from "ACCOUNT2" where "ACCOUNT2"."ID" = :p0) where rownum = 1
Bindings : [461060]
(SQL: select * from (select * from "ACCOUNT2" where "ACCOUNT2"."ID" = 461060) where rownum = 1)

问题是......

  1. 我们是否可以删除双引号?
  2. 如果没有,我们如何阻止框架更改表和字段名称的大小写?
  3. 我尝试在app / database.php中配置oracle驱动器     'options'=> [PDO :: ATTR_CASE => PDO :: CASE_UPPER,//启用此中断模型关系] ,但这打破了模型关系(例如,$ user-> account-> id,将尝试访问非对象异常作为用户帐户将返回null而不是如上所述设置选项,关系不会被破坏。)

0 个答案:

没有答案
相关问题