簡體   English   中英

從“視圖”中選擇,導致PHP和SQL Server中的執行超時

[英]Select from 'view' causing execution timeout in PHP and SQL Server

我創建了一個名為statsview ,該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

視圖創建良好,當我說SQL Server Management Studio中的SELECT * FROM stats ,結果顯示良好。

問題是當我使用PHP抓取數據時:

$GRAB_STATS_DATA = $DBH->query("SELECT * FROM stats");
while($row = $GRAB_STATS_DATA->fetch()){
    $attribute1 = $row['attribute1'];
    ... // and so on
}

我收到一條錯誤消息: [PHP Fatal error: Maximum execution time of 300 seconds exceeded in C:\\ ... on line 17]

為什么上述使用PHP的超時(或執行時間超過300秒)卻在SQL Server Management Studio中顯示正常?

采用:

foreach ($GRAB_STATS_DATA->fetchAll() as $row){
  $attribute1 = $row['attribute1'];
    ... // and so on
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM