I would like to test the following garbage collector code on a database of sessions. It should be following the conditions below:
- if 'remember me' is enabled by the user, then it should delete all rows which are not active within 2 weeks.
- if 'remember me' is disabled by the user, then it should delete all rows which are not active within 30 minutes.
I have times inserted in the LAST_ACTIVITY
column, with the UNIX_TIMESTAMP()
format.
public function gc( $maxlifetime )
{
$this->conn->SQL( 'DELETE FROM session WHERE (LAST_ACTIVITY < ? AND REMEMBERUSER = ?) OR (LAST_ACTIVITY < ? AND REMEMBERUSER = ?)' ,
[ strtotime('-30 minutes'), 'N' , strtotime('-2 weeks'), 'Y']);
return true;
}
Are the AND
or OR
operators working properly? I would only like to test the SQL query, and not the gc method.