The following code should do this:
$where = "SessionExpires < DATE_SUB( NOW( ) , INTERVAL 10 MINUTE )";
$this->db->where($where, null, false);
$this->db->delete('ChatSessions');
You can also try the following (but I don't know if this will work):
$where_condition = "DATE_SUB( NOW( ) , INTERVAL 10 MINUTE )";
$this->db->where("SessionExpires <", $where_condition, false);
$this->db->delete('ChatSessions');
source
share