This is what i am trying to do.
id ip timestamp userid
9 127.0.0.1 2013-06-27 16:52:49 35
I would like to first query table to see if ip for the user is persisted. If so, he/she voted 2) Check timestamp of vote against current timestamp, if his voting time is way after 24 hours, then allow him to vote again. Ensure he can only vote once in 24 hours.
This is my current zend_db_select statement. Has some problems coming out with the logic
function checkIfCanLikeH($hlid,$ip){
$canlike = false;
$currenttime = time();
$checkquery = $this->dbo->select()
->from("hl", array("num"=>"COUNT(*)"))
->where("hlid = ?", $hlid)
->where("ip = ?", $ip)
->where("timestamp < ".new Zend_Db_Expr('NOW()'));
$this->dbo->setFetchMode(Zend_Db::FETCH_ASSOC);
$checkrequest = $this->dbo->fetchRow($checkquery);
if($checkrequest['num']!=0){
$ip = true;
}
return $ip;
}
I am stucked at how do i compare the timestamp. I need retrieve the timestamp from table and check if the current time is smaller than value in table (added 24 hours).
Advice appreciated.