請大家幫我檢查我的語法是否正確。我沒有使用這段代碼得到任何錯誤,但我只是想對我是否正確地做出正確的幾點意見。用小於和大於時間的查詢
我使用的是多站點WordPress安裝,我檢查,看看是否該功能的博客是不是每天超過一個星期舊舊的,但少:
/* Work out blog of the day */
$featured_id = get_option('featured_blog'); # Current ID
$featured_time = get_option('featured_time'); # Current Time
if($featured_time > time()-86400 && $featured_time < time()-604800) // more than 1 Day ago but less than a week
{
$query = "SELECT blog_id FROM `wp_blogs` WHERE public = '1' and archived = '0' and spam = '0' and deleted = '0' AND blog_id NOT IN ('".$featured_id."', '1','27') ORDER BY rand() limit 1";
$featured_id = $wpdb->get_var($query);
update_option('featured_blog', $featured_id);
update_option('featured_time', time());
}
如果沒有錯誤,你做得很對。爲了確定它是否好,你可以考慮系統時間和數據庫時間之間的差異。 –
你搖滾!謝謝 ! – DFreeman