首页 > 代码库 > 批量恢复zencart产品表master_categories_id=0的产品
批量恢复zencart产品表master_categories_id=0的产品
批量恢复zencart产品表所属分类master_categories_id为0的产品
将下面代码保存为master_categories_id.php,上传到网站根目录运行即可,操作前先备份数据库
<?phpheader("content-Type: text/html; charset=utf-8"); /***批量恢复zencart产品表master_categories_id为0的产品***/require(‘includes/application_top.php‘);echo ‘正在处理...‘;$products_query = "select products_id from " . TABLE_PRODUCTS . " where master_categories_id = ‘0‘ order by products_id";$products = $db->Execute($products_query);$id_array = array();while(!$products->EOF){ $id_array[] = $products->fields[‘products_id‘]; $products->MoveNext(); }foreach($id_array as $val){ $categories_id = $db->Execute("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = ‘".(int)$val."‘ limit 0,1"); if($categories_id->fields[‘categories_id‘]){ $products=$db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id = ‘" .$categories_id->fields[‘categories_id‘]. "‘ where products_id = " . (int)$val); }}echo ‘OK!处理完毕‘;require(DIR_WS_INCLUDES . ‘application_bottom.php‘);?>
批量恢复zencart产品表master_categories_id=0的产品
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。