这是我放入数据库的查询。我的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根本不起作用。