Witam usiłuję poprawić funkcję usuwania czasowego z bazy wpisów z czata
public static function getUsers(){
if($_SESSION['user']['name']){
$user = new ChatUser(array('name' => $_SESSION['user']['name']));
$user->update();
};
DB::query("DELETE FROM webchat_lines WHERE ts< SUBTIME(NOW(),'0:5:0')");
DB::query("DELETE FROM webchat_users WHERE last_activity< SUBTIME(NOW(),'0:10:0')");
$result = DB::query('SELECT * FROM webchat_users ORDER BY name ASC LIMIT 18');
$users = array();
while($user = $result->fetch_object()){
$user->gravatar = Chat::gravatarFromHash($user->gravatar,30);
$users[] = $user;
}
return array(
'users' => $users,
'total' => DB::query('SELECT COUNT(*) as cnt FROM webchat_users')->fetch_object()->cnt
);
}
zapytanie
DB::query("DELETE FROM webchat_lines WHERE ts< SUBTIME(NOW(),'0:5:0')"); usuwa czasowo ale wszystkie,a chcę aby zostały id ostatnie 10,coś w stylu id>10.