tp6 withJoin 与 withoutField 连用时会数据库报错

浏览:1226 发布日期:2021/06/08
5.0.0 - 普通 - 未处理
当查询时withJosn 与 withoutField 一起使用时,
回报 1052 - Column 'id' in field list is ambiguous 类的sql错误。
跟踪sql 语句发现:
SELECT `news`.`id`,`news`.`title`,`news`.`logo`,`news`.`up_date`,`news`.`position`,`news`.`recommand`,`news`.`cid`,`news`.`parentid`,`news`.`click`,`news`.`wxclick`,`news`.`flag`,`news`.`body`,`news`.`url`,`news`.`adminid`,`news`.`description`,`news`.`attachment`,`news`.`good`,`newsClass`.`id` AS `newsClass__id`,`newsClass`.`name` AS `newsClass__name`,`newsClass`.`parentid` AS `newsClass__parentid`,`newsClass`.`description` AS `newsClass__description`,`newsClass`.`adminid` AS `newsClass__adminid`,`newsClass`.`sort` AS `newsClass__sort`, `id`,`title`,`up_date`,`position`,`recommand`,`cid`,`parentid`,`click`,`wxclick`,`flag`,`url`,`adminid`,`attachment`,`good`
FROM `ser_news` `news` INNER JOIN `ser_news_class` `newsClass` ON `news`.`cid`=`newsClass`.`id` ORDER BY `news`.`id` DESC LIMIT 0,15

在自动生成的自动列表后会再次出现 主表的字段列表(排除了不需要的字段的)`id`,`title`,`up_date`,`position`,`recommand`,`cid`,`parentid`,`click`,`wxclick`,`flag`,`url`,`adminid`,`attachment`,`good`
评论(
后面还有条评论,点击查看>>