求各位前辈帮忙看看连表查询前缀问题
求各位前辈帮看看这个为什么指定别名会自动加上表前缀啊
在模型里我加上了
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 协议》,转载必须注明作者和本文链接
没记错的话,应该是在 config/database.php 中的 connections.mysql.prefix 有设定
@DotDotHom 是这样的前辈,我在里面已经设置了,因为我每张表都有前缀
这里的
find_in_set(1, class_type)
是当字段处理了吗?要使用find_in_set 函数处理字段应该是
whereRaw("find_in_set($service_id, class_type)")