致命错误:耗尽了536870912字节的允许的内存大小(尝试分配1023字节)

时间:2018-12-06 07:29:04

标签: php sql apache optimization

我正在从SQL数据的结果集中创建格式化的数组。

这是我的代码:

    $sql = "exec csp_CompleteDataDump_Back @startDate='2018-11-16 18:30:00',@endDate='2018-11-30 18:30:00'";


    $stmt = sqlsrv_query( $conn, $sql );
    if( $stmt === false) {
        echo "<pre>";
        die( print_r( sqlsrv_errors(), true) );
    }


    $ticket_ids = array();
    $excel_arr = array();
    $cnt = 0;
    while( $rs = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {

        $excel_arr[$cnt] = $rs;

        $excel_arr[$cnt]['Row No'] = $cnt+1;

        $excel_arr[$cnt]['Created Date'] = date_formats($rs['Created Date'],11,false);
        $excel_arr[$cnt]['Closure Date'] = date_formats($rs['Closure Date'],11,false);
        $excel_arr[$cnt]['Modified Date'] = date_formats($rs['Modified Date'],11,false);

        $excel_arr[$cnt]['Branch Name'] = $GLOBALS['app_list_strings']['sub_branch_list'][$rs['Branch Name']];
        $excel_arr[$cnt]['Caller Relation'] = $GLOBALS['app_list_strings']['caller_relation_list'][$rs['Caller Relation']];
        $excel_arr[$cnt]['Priority'] = $GLOBALS['app_list_strings']['case_priority_dom'][$rs['Priority']];
        $excel_arr[$cnt]['Source'] = $GLOBALS['app_list_strings']['source_list'][$rs['Source']];

        $excel_arr[$cnt]['Contact Status'] = $GLOBALS['app_list_strings']['contact_status'][$rs['Contact Status']];
        $excel_arr[$cnt]['Resolution Category'] = $GLOBALS['app_list_strings']['resolution_category'][$rs['Resolution Category']];
        $excel_arr[$cnt]['Root Cause'] = $GLOBALS['app_list_strings']['root_cause'][$rs['Root Cause']];
        $excel_arr[$cnt]['Service Status'] = $GLOBALS['app_list_strings']['service_status_list'][trim($rs['Service Status'])];
        $excel_arr[$cnt]['Res In Favour Of Customer'] = $GLOBALS['app_list_strings']['res_in_fav_of_customer'][$rs['Res In Favour Of Customer']];

        $excel_arr[$cnt]['Work Note'] = sanitize_string($rs['Work Note']);

        $cnt++;
    }

当SP中传递的日期差较小时,此脚本成功运行。 例如

    $sql = "exec csp_CompleteDataDump_Back @startDate='2018-11-16 18:30:00',@endDate='2018-11-20 18:30:00'";

但是,一旦日期差增加,它就会开始抛出致命错误以下的消息:

    Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 1023 bytes)

我使用了 ini_set('memory_limit','-1'); ,但这给了我同样的错误。

有人知道为什么会这样吗?

0 个答案:

没有答案