获取大数据时我的sql连接超时

时间:2013-12-20 05:49:33

标签: php mysql database-connection

我在tbl_user表中有超过1个lac用户,我想选择所有用户ID并使用每个用户ID 用户ID我正在努力获得终身积分&为每个用户使用点数和可用点数 如下所述,

   $get_all_userid_qry = "SELECT user_id FROM tbl_user WHERE site_id=12345 AND             active='1'";
   $get_all_userid = $con->fetchAll($get_all_userid_qry);

    //echo '<pre>';print_r($get_all_userid);exit();

   $available_points_array = array();
   $points_threshold_Distribution_data = array();

   $userCount = count($get_all_userid);



    for($i = 0; $i < $userCount; $i++)
    {
        $name_points_qry =  "SELECT sum(earned_points) as points FROM tbl_points WHERE site_id=12345 AND user_id='".$get_all_userid[$i]->user_id."' ";
        $name_points_row = $con->fetchRow($name_points_qry);

        $lifetime_points = $name_points_row->points;

        //get used points by user

        $get_used_points = "select sum(points_used) as used_pts from tbl_claimed WHERE site_id=12345 AND user_id='".$get_all_userid[$i]->user_id."' ";
        $get_used_points_row= $con->fetchRow($get_used_points);

        $used_points = $get_used_points_row->used_pts;

        $available_points = $lifetime_points - $used_points;
        $available_points_array[] = $available_points;
    }

但是,我发现从tbl_user中选择所有用户ID很困难,因为我的sql连接中间有时间,而且当我使用print_r()时它没有显示完整的结果数组。

请建议如何选择大量数据。

1 个答案:

答案 0 :(得分:0)

在您打开php标签之前输入:

ini_set('memory_limit', '2048M');

或者您可以在htaccess文件中添加以下行:

php_value memory_limit 64M

希望它有所帮助!