PHP 5.3 Windows 数组赋值导致错误
我很难理解为什么 PHP 在执行以下代码块时没有反馈或错误(除了 Windows 错误日志、php5 错误模块 php 中的错误)而出现错误:
$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
}
无论从 sql 资源中提取对象还是数组,结果都是相同的,有问题的行是数组赋值。
在大约 9100 条记录之后,该分配会导致 php 出现错误。
如果这个循环被计算出来,那么执行终止是受控的,我可以看到php消耗了大约25mb的内存,根据它的配置,它允许256个
。错误记录并不总是相同的,它可能会因3或4个索引而异。
该代码实际上毫无意义,但以某种方式对同一产品 ID 的记录进行分组,但我很想知道它会做什么,可能会导致 php 突然死掉。
感谢您抽出时间。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你所说的错误是什么意思。但如果这意味着它使脚本终止,我建议启用错误日志并查看最终错误消息的内容。无论如何,它可能是一个 PHP 错误,因此始终建议您将其报告到 http://bugs.php。 net/,因为这是 PHP 开发人员查看最终错误的正确位置。
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.