douxia1988 2012-09-30 00:07
浏览 73

MySQL服务器已经消失 - 在mysql php循环之后

I'm making a query over a database with over 20MM entries, that means im breaking the query into several smaller queries.

The problem is if I try to fetch the 20MM entries the page does not load and gets the notice: MySQL server has gone away, and displays a blank screen, with no title and content. However, if I fetch 5MM entries, the page does load correctly, and displays the content:

Here's my code

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
ini_set('memory_limit', '1000M');
for($n=0; $n<20000000; $n=$n+500000){
    $m=500000;
$query = "SELECT * FROM user_likes LIMIT ". $n .",". $m; 
//echo $query;
$result = mysql_query($query) or die(mysql_error());

// craete arrays
while($row = mysql_fetch_array($result)){
    set_time_limit(0);
    $like[$row['name']]=$like[$row['name']]+1;
    if($like[$row['name']]==375) $likes375 ++; 

}


}

// print the size
echo count($like)."<br>";
echo "375: ".$likes375; 

I would appreciate if someone can help me with this. Thanks

  • 写回答

4条回答 默认 最新

  • doumeilmikv7099 2012-09-30 00:17
    关注

    Sounds like your backing it up and your going to have to wait for it to finish and you maximum execution time for php is shorter than its going to take for the query to finish. Suggestion is to do what you need to do in smaller chunks.

    评论

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来