首页 > 网站 > 建站经验 > 正文

Shopex转到Ecshop后,商品相册图片数据重复的解决

2024-04-25 20:41:19
字体:
来源:转载
供稿:网友

<?php

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

$q = $db->getAll("SELECT DISTINCT `img_url` FROM ". $ecs->table('goods_gallery'));

foreach($q as $key => $val){

$c = intval($db->getOne("SELECT count(0) FROM ". $ecs->table('goods_gallery') ." WHERE img_url='". $val['img_url'] ."'"));

if($c>1){

$c = intval($db->getOne("SELECT img_id FROM ". $ecs->table('goods_gallery') ." WHERE img_url='". $val['img_url'] ."' ORDER BY img_id LIMIT 0,1"));

if($c>0){

$sql = "DELETE FROM " . $ecs->table('goods_gallery') . " WHERE img_id <> ". $c ." and img_url='". $val['img_url'] ."'";

$db->query($sql);

}

}

}

?>

将以上内容保存成为一个php文件 运行即可

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表