shopex~ecshop数据转换成功后,商品图片重复很多个

2016-07-07 15:14 来源:www.chinab4c.com 作者:ecshop专家



  1. <?php
  2. define('IN_ECS', true);
  3. require(dirname(__FILE__) . '/includes/init.php');
  4. $q = $db->getAll("SELECT DISTINCT `img_url` FROM ". $ecs->table('goods_gallery'));
  5. foreach($q as $key => $val){
  6. $c = intval($db->getOne("SELECT count(0) FROM ". $ecs->table('goods_gallery') ." WHERE img_url='". $val['img_url'] ."'"));
  7. if($c>1){
  8. $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"));
  9. if($c>0){
  10. $sql = "DELETE FROM " . $ecs->table('goods_gallery') . " WHERE img_id <> ". $c ." and img_url='". $val['img_url'] ."'";
  11. $db->query($sql);
  12. }
  13. }
  14. }
  15. ?>
复制代码



上面这个代码是我在百度搜到的解决办法,地址:http://www.cnblogs.com/imbin/archive/2010/07/06/1772333.html
但是把文件传到根目录结果提示:

  1. Fatal error: Maximum execution time of 30 seconds exceeded in D:\idcbjhost\ichumi\web\includes\cls_mysql.php on line 267

  2. Fatal error: Maximum execution time of 30 seconds exceeded in D:\idcbjhost\ichumi\web\includes\cls_session.php on line 233
复制代码


求解,请高人指点一下!

回答:
这个SQL和循环有问题。执行时间超时

记号下
谢谢主