当我直接放入数据库而不是通过PHP的查询时,查询工作

时间:2014-01-31 02:54:38

标签: php mysql sql

这是我放入数据库的查询。我的mysql数据库是UTC格式,但我的数据输入美国东部

SET time_zone = '-6:00';
SELECT HOUR(created_at), count(*) AS sent
FROM tweets
WHERE created_at
BETWEEN CURDATE()
AND NOW()
GROUP BY HOUR(created_at)
ORDER BY HOUR(created_at)

我的php看起来像:

$q = "SET time_zone = '-6:00'; 
SELECT HOUR(created_at), count(*) AS sent FROM tweets
WHERE created_at
BETWEEN CURDATE()
AND NOW()
GROUP BY HOUR(created_at)
ORDER BY HOUR(created_at)";

$r = @mysqli_query ($dbc, $q);

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {

echo "[".$row['HOUR(created_at)'].",".$row['sent']."],";

是否有任何理由直接插入数据库工作正常并返回结果,而php根本不起作用。

0 个答案:

没有答案