我正在製作一個類似於facebook的網站。爲此,我想實施「長輪詢」以動態更新用戶牆上的新帖子。CakePHP:如何根據創建時間從數據庫獲取數據
這裏是我所計劃
//when user first open my website
loadPostsNormally();
var lastTime = current_time;
function update(){
$.getJSON('/some_other_page_which_will_fetch_the_contents_created_after_lastTime_and_encode_it_to_json/'+lastTime,function(){
lastTime = current_time;
showNewPostsOnWall();
}
setInterval(update,2000);
現在的問題是我的頁面僞碼some_other_page_which_will_fetch_the_contents_created_after_lastTime_and_encode_it_to_json
public function some_other_page_which_will_fetch_the_contents_created_after_lastTime_and_encode_it_to_json($timestamp){
//fetch_all_data_created_after_this_timestamp_but_how ??
}
我想從我的Post模型來獲取,並在時間我的「創建'的職位表字段就像2014-11-19 22:34:09
對不起,使用非常通俗的語言來描述問題。我之所以這樣做,是因爲我還沒有開始,我只是在制定計劃來解決這個問題。
我在您的文章中看不到問題... – thatidiotguy 2014-11-20 18:07:20
我想知道如何獲取在CakePHP中給定時間後創建的所有數據 – user3774654 2014-11-20 18:09:11