SQL删除某个ID商品、列表属性,与及相关的资料呢?

2016-07-07 16:17 来源:www.chinab4c.com 作者:ecshop专家

SQL删除某个ID商品、列表属性,与及相关的资料呢?

V2.7.0 。。除了删除商品,列表属性,还有没有别的要删除的?我不想删除了还有多余的信息残留,影响数据库的使用率。。

各位路过的同仁,希望你不惜手酸,赐教下。。

回答:
属性列表是共用的,删除了会影响其他商品的属性的.

楼上说的对



参照admin/includes/lib_goods.php 中的delete_goods($goods_id)函数,就能看出有多少相关表需要删除了

/* 删除相关表记录 */
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_article') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_attr') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_cat') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('member_price') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE parent_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('link_goods') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('link_goods') . " WHERE link_goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('tag') . " WHERE goods_id " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('comment') . " WHERE comment_type = 0 AND id_value " . db_create_in($goods_id);
$GLOBALS['db']->query($sql);