ThinkPHP ‘information_schema.tables‘ 无效

本文讨论了Think-ORM中Sqlsrv.php中的SQL错误,因information_schema表名大小写敏感。提供了解决方案:调整表名为大写。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误见下图:

错误SQL语句:

SELECT column_name, data_type, column_default, is_nullable 
  FROM information_schema.tables AS t 
  JOIN information_schema.columns AS c ON t.table_catalog = c.table_catalog 
  AND t.table_schema = c.table_schema 
  AND t.table_name = c.table_name WHERE t.table_name = 'TAB01'

 错误原因:

     'information_schema.tables' 无效,字面意思就是information_schema数据库或tables表不存在。在sqlserve中数据库名称(表名称)启用了区分大小写

修复方法(将Sqlsrv.php文件下的SQL改成大写)如下:

将"TP\vendor\topthink\think-orm\src\db\connector\Sqlsrv.php"文件中getFields方法的SQL语句中的information_schema.tablesinformation_schema.columns以及information_schema.key_column_usage改成大写

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值