服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: 130-5800-8007
当前位置: 主页 > php教程 > zencart教程 >

批量恢复zencart产品表所属分类master_categories_id为

时间:2016-05-28 11:12来源: 作者: 点击:
将下面代码保存为master_categories_id.php,上传到网站根目录运行即可,操作前先备份数据库 ? php header (content-Type: text/html; charset=utf-8 ); /* **批量恢复zencart产品表master_categories_id 为 0的产品

将下面代码保存为master_categories_id.php,上传到网站根目录运行即可,操作前先备份数据库

复制代码
<?php
header("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');
?>
复制代码

(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容