I have created a view called stats that selects the sum of records that adhere to a certain attribute
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.
The problem is when I use PHP to grab the data:
$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]
Why does the above timeout using PHP (or take longer than 300sec to execute) but display fine in SQL Server Management Studio?
die()just before thewhile()and the page refreshes fast, only the information is not displayed. So it seems that the time is exceeded before thewhile()?foreach($GRAB_STATS_DATA->fetchAll() as $row){