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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题