duangu9997 2019-08-02 08:34
浏览 12
已采纳

PHP - 生成许多产品Feed,最大执行时间错误

I have an ecommerce site and am trying to generate product feeds for Googles merchant center.

It started out as one product feed for one country, one language and one currency, as we're growing we've a number for different feeds for numerous languages, different prices for different regions.

I had just been creating them manually but want to improve this so I've created a database of the combinations of countries languages and currencies that we want and took out the basic structure for generating it and put it in a function.

So now I have something like this:

$sql = "SELECT * FROM product_feeds";
$stmt = DB::run($sql);
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
    $country = $row['country'];
    $currency = $row['currency'];
    $language = $row['language'];

    generate_product_feeds($country,$currency,$language);
}

This kind of works fine. The issue is it will get through about two or three product feeds before I get a maximum execution time error.

Is there a way to stall the functions or do this in seperate requests so it will run properly.

  • 写回答

1条回答 默认 最新

  • dongwu8653 2019-08-09 09:09
    关注

    This was being done by a cron job every night so I just changed my cron settings to every minute for an hour and did the original query based on the minutes, like so:

    $params = [date('i')];
    $sql = "SELECT * FROM product_feeds WHERE id=?";
    $stmt = DB::run($sql,$params);
    

    Obviously I'll have to change this if I get above 60 but the script can handle about 2 or 3 product feeds at a time so I can probably do it in multiples. And for my purposes I don't think it will even reach 60.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?