我正在制作一个类似于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