简体   繁体   中英

PHP 5.3 Windows Array assignment causes fault

I am struggling to understand why PHP is faulting without feedback or error (beyond windows error log, fault in php5 faulting module php) whilst executing the following block of code:

$projects = array(); 
    $pqRes = $connection->getResult("SELECT big query");         

    //build an array by project id
    while($record = sqlsrv_fetch_array($pqRes))
    {
        if(! array_key_exists($record['ProjectID'],$projects))
          {
              $projects[$record['ProjectID']] = array();
          }

          $projects[$record['ProjectID']][] = $record;   //this line faults php after about 9100 records
    }

The outcome is the same whether objects or arrays are pulled from the sql resource, and the offending line is the array assignment.

The assignment causes a fault in php after around 9100 records.

If this loop was counted out so execution termination is controlled I can see that php has consumed about 25mb of memory, by its configuration it is allowed 256.

The faulting record is not always the same, it can vary by 3 or 4 indexes.

The code is in fact quite pointless but in a round about way groups records of the same productID, but I am very interested to know what it could do that might cause php to die so suddenly.

Thanks for your time.

I am not sure what you mean by a fault. But if it means it makes the script terminate, I suggest enabling error log and see what the final error message says. In any case, it may be a PHP bug, so you are always recommended to report it to http://bugs.php.net/ , as that is the right place where PHP developers look at eventual bugs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM