Thinkphp5,Thinkphp6关联模型hasWhere跨库查询报错解决
2023-03-29 23:03:03
101
{{single.collect_count}}

代码:这里channelGame关系是另一个数据库下的表

报错:数据库表不存在

原因分析:查询的时候没有加关联库前缀ssyx_tuiguang,然后默认加了查询库的前缀 ssyx_game

解决办法

把:

修改为:

问题解决完毕

注意,每个关联类(HasOne.php, HasMany.php ... )里的hasWhere方法都要这样改

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}