求各位前辈帮忙看看连表查询前缀问题

求各位前辈帮看看这个为什么指定别名会自动加上表前缀啊
在模型里我加上了
protected $table = ‘platform_game’;

 $game_list = Db::table('platform_game a')
 ->select(['a.id,a.name,a.name_en,a.name_path,b.thumb_img,list_order'])
            ->leftJoin('platform_game_extension b FORCE INDEX(index_game_id)', 'a.id','=','b.game_id')
            ->where($where)
            ->where("find_in_set($service_id, class_type)")
            ->orderBy('a.recommend','desc')
            ->orderBy('a.list_order','desc')
            ->limit(4)
             ->dd();
实际sql打印:
select `jc_a`.`id,a`.`name,a`.`name_en,a`.`name_path,b`.`thumb_img,list_order` from `jc_platform_game a` left join `jc_platform_game_extension b FORCE INDEX(index_game_id)` on `jc_a`.`id` = `jc_b`.`game_id` where (`jc_a`.`parent_id` = ? and `is_show` = ?) and `find_in_set(1, class_type)` is null order by `jc_a`.`recommend` desc, `jc_a`.`list_order` desc limit 4
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 3

没记错的话,应该是在 config/database.php 中的 connections.mysql.prefix 有设定

5年前 评论

@DotDotHom 是这样的前辈,我在里面已经设置了,因为我每张表都有前缀

5年前 评论
DotO 5年前
一个人看电影 (作者) (楼主) 5年前

这里的 find_in_set(1, class_type) 是当字段处理了吗?

要使用find_in_set 函数处理字段应该是whereRaw("find_in_set($service_id, class_type)")

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!