<?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文件 运行即可
新闻热点
疑难解答