duanli3277 2019-06-14 11:49
浏览 91

通过比较时间()设置每日限额

I'm creating a script where by inserting comments credits are assigned. These actions are recorded in a table in the database called "Activity", with the user field (other) and the insertion date of this "posted" action.

I would like to limit the assignment of credits if the counting of the actions on the current day by the user exceeds a TOT.

So if the user has already entered 10 comments today, the credits are no longer placed. My dilemma is that being the date in time () I can't get the date through.

I am using codeigniter, my little code also using the template is this:

$today = mktime (0,0,0, date('d'), date('m'), date('Y'));
if ($this->default_model->limitCreditiDay($user->id, $today) > 2) {
    echo 'No';
} else {
        echo 'Yes';
}

I used mktime thinking to return the date in time through the date () fields, but nothing, the results are always 0 because I will miss something.

The model draws the count of the results where in activity the user and date. How can I solve it?

EDIT***

public function limiteCreditiDay($idUser, $oggi, $domani){
   $this->db->select('id');
   $this->db->from('attivita');
   $this->db->where('idUser', $idUser);
   $this->db->where('posted BETWEEN '.$oggi.' AND '.$domani);
   return $this->db->count_all_results();

}


$oggi = mktime(date('m'), date('d'), date('Y'));
$domani = mktime(date('m'), date('d')+1, date('Y'));
$idUser = 1;
echo $this->default_model->limiteCreditiDay($idUser, $oggi, $domani); 

But nothing!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码