2
我需要查看用PHP/MySQL編寫的測試應用程序的一些代碼。 此代碼的作者寫了三個SQL查詢。 我不明白,如果他在這裏的意思是一些性能優化?第一查詢的SQL代碼在評論代碼中的含義
DB::fetch("SELECT COUNT(* ) AS count, `ip`,`datetime`
FROM `logs`
WHERE `datetime` > ('2006-02-03' - INTERVAL 10 DAY)
GROUP BY `ip`
ORDER BY `datetime` DESC");
$hits = DB::fetchAll("SELECT COUNT(* ) AS count, `datetime`
FROM `logs`
WHERE `datetime` > ('2006-02-03' - INTERVAL 10
DAY) AND `is_doc` = 1
GROUP BY `datetime`
ORDER BY `datetime` DESC");
$hosts = DB::fetchAll("SELECT COUNT(* ) AS hosts , datetime
FROM (
SELECT `ip` , datetime
FROM `logs`
WHERE `is_doc` = 1
GROUP BY `datetime` , `ip`
ORDER BY `logs`.`datetime` DESC
) AS cnt
WHERE cnt.datetime > ('2006-02-03' - INTERVAL 10
DAY)
GROUP BY cnt.datetime
ORDER BY datetime DESC ");
結果應用不使用。
雅看起來只是一些報告在日誌中捕獲的任何東西 – Wil 2010-08-31 12:50:28