Array ( [errno] => 1064

2016-07-07 15:51 来源:www.chinab4c.com 作者:ecshop专家

修复了`ecs_link_goods`等很多表,修复成功了,但还是不行
重启服务器也不行

回答:
请高手指点

这个应该是SQL语句的问题,楼上的没修改过代码吧?

一点都没修过,用的是默认模板

那你肯定修改过数据库了

请高手搞定的,公布如下以方便遇到同样问题者:

改的地方是根目录下goods.php文件的get_linked_goods函数
第229行
之前是"LIMIT " . $GLOBALS['_CFG']['related_goods_number'];
如果related_goods_number为空的话,就会报错
这里增加了一个判断,对不同情况进行不同的处理

原来的代码:

* 获得指定商品的关联商品
*
* @accesspublic
* @paraminteger$goods_id
* @returnarray
*/
function get_linked_goods($goods_id)
{
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' .
'FROM ' . $GLOBALS['ecs']->table('link_goods') . ' lg ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = lg.link_goods_id ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
"WHERE lg.goods_id = '$goods_id' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ".
"LIMIT " . $GLOBALS['_CFG']['related_goods_number'];
$res = $GLOBALS['db']->query($sql);

改后的代码:
* 获得指定商品的关联商品
*
* @accesspublic
* @paraminteger$goods_id
* @returnarray
*/
function get_linked_goods($goods_id)
{
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' .
'FROM ' . $GLOBALS['ecs']->table('link_goods') . ' lg ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = lg.link_goods_id ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
"WHERE lg.goods_id = '$goods_id' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ";
$sql .= $GLOBALS['_CFG']['related_goods_number'] ? " LIMIT " . $GLOBALS['_CFG']['related_goods_number'] : '';
$res = $GLOBALS['db']->query($sql);

呵呵,楼主过奖了
这个问题是因为没有在后台设置关联商品的数量而导致的。
然而程序这里没有对“关联商品设置为空”的条件进行判断,所以导致的这个问题。