我有一个相当大的firebird数据库,我试图从中获取数据,我使用pdo类,并且这样使用它:
for($i=0; $i < $hours; $i++):
$date = date('H:i:s',strtotime("+$i hour"));
$newdate = date('H:i:s', strtotime($date . "+1 hour"));
$sql = "SELECT count(*) as NUMBER FROM BANDZENDINGEN WHERE FT_TIJD_INGEVOERD BETWEEN '".$date."' AND '".$newdate."' AND FI_GEBRUIKER1='56'";
$count = $dbh->query($sql)->fetchColumn();
endfor;
这很简单,我给出了几个小时,在这个小时中,该查询为用户计算了导入次数。示例:
$hours = 4;
SELECT count(*) as NUMBER FROM BANDZENDINGEN WHERE FT_TIJD_INGEVOERD BETWEEN '08:40:57' AND '09:40:57' AND FI_GEBRUIKER1='56'
SELECT count(*) as NUMBER FROM BANDZENDINGEN WHERE FT_TIJD_INGEVOERD BETWEEN '09:40:57' AND '10:40:57' AND FI_GEBRUIKER1='56'
SELECT count(*) as NUMBER FROM BANDZENDINGEN WHERE FT_TIJD_INGEVOERD BETWEEN '10:40:57' AND '11:40:57' AND FI_GEBRUIKER1='56'
SELECT count(*) as NUMBER FROM BANDZENDINGEN WHERE FT_TIJD_INGEVOERD BETWEEN '11:40:57' AND '12:40:57' AND FI_GEBRUIKER1='56'
问题是$ count = $ dbh-> query($ sql)-> fetchColumn();给我一个错误503-服务不可用!如果我在数据库内执行此查询(RazorSql),则只需19秒即可完成。我究竟做错了什么?请帮忙。