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!