ecshop系列:后台导出程序错误,ecshop应该认错

今天一个客户给我发来ecshop后台导出出现

ERROR 1052 (23000): Column ‘brand_id’ in where clause is ambiguous

经查发现是不同表存在相同字段而在where 语句中未区分造成

测试运行语句

SELECT g.*, b.brand_name as brandname FROM `usason`.`ecs_goods` AS g LEFT JOIN `usason`.`ecs_brand` AS b ON g.brand_id = b.brand_id WHERE is_delete = 0 AND brand_id = ’17’;

修改为

SELECT g.*, b.brand_name as brandname FROM `usason`.`ecs_goods` AS g LEFT JOIN `usason`.`ecs_brand` AS b ON g.brand_id = b.brand_id WHERE is_delete = 0 AND g.brand_id = ’17’;

红色部分注意

那么就只有去查后台程序代码了

发现在admin/includes/lib_main.php 的get_where_sql($filter)的函数中出现了

$where .= isset($filter->brand_id) && $filter->brand_id > 0 ? ” AND brand_id = ‘” . $filter->brand_id . “‘” : ”;

修改为

$where .= isset($filter->brand_id) && $filter->brand_id > 0 ? ” AND g.brand_id = ‘” . $filter->brand_id . “‘” : ”;

问题解决

目前还不知道有其他副作用

好在ecshop命名还算规范

 

发表评论

邮箱地址不会被公开。 必填项已用*标注