[英]Select from 'view' causing execution timeout in PHP and SQL Server
I have created a view
called stats
that selects the sum of records that adhere to a certain attribute 我创建了一个名为stats
的view
,该view
选择符合特定属性的记录总数
CREATE VIEW stats
AS
SELECT
SUM(CASE WHEN attribute = '1' THEN 1 ELSE 0 END) AS attribute1,
SUM(CASE WHEN attribute = '2' THEN 1 ELSE 0 END) AS attribute2
FROM table
GO
The view is created fine and when I say SELECT * FROM stats
in SQL Server Management Studio the results show up fine. 视图创建良好,当我说SQL Server Management Studio中的SELECT * FROM stats
,结果显示良好。
The problem is when I use PHP to grab the data: 问题是当我使用PHP抓取数据时:
$GRAB_STATS_DATA = $DBH->query("SELECT * FROM stats");
while($row = $GRAB_STATS_DATA->fetch()){
$attribute1 = $row['attribute1'];
... // and so on
}
I get an error saying [PHP Fatal error: Maximum execution time of 300 seconds exceeded in C:\\ ... on line 17]
我收到一条错误消息: [PHP Fatal error: Maximum execution time of 300 seconds exceeded in C:\\ ... on line 17]
Why does the above timeout using PHP (or take longer than 300sec to execute) but display fine in SQL Server Management Studio? 为什么上述使用PHP的超时(或执行时间超过300秒)却在SQL Server Management Studio中显示正常?
Use: 采用:
foreach ($GRAB_STATS_DATA->fetchAll() as $row){
$attribute1 = $row['attribute1'];
... // and so on
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.