php - Unable to delete row in codeigniter
I want when thetiming
date in CodeIgniter is less than current date then it should delete the row auto.
I have a table nameddoctor
. The fields areid(int)
,crated_at(timestamp)
timings(varchar)
,name(varchar)
.
I use to insert the timing inmm/dd/yyyy
format. I want when the date is less than the current date then is should delete the row auto.
MODEL
public function delete_book(){
$date = date("m/d/Y");
$this->db->where("timings < (".$date." - INTERVAL 1 DAY)");
$this->db->delete("doctors");
}
Please let me know about the fault of my code
Answer
Solution:
Use this
Answer
Solution:
You should use
NOW()
function of MySql.NOW()
returns the date of the system and it is also compatible with MySql query.Answer
Solution:
Will work may use
Hope fully works.
Answer
Solution:
You may use DATE_SUB function
above function produced query is :-