3raser Posted June 20, 2012 Share Posted June 20, 2012 I don't have too much experience with PDO, but I want to remove all inactive users from online_users WHERE time() - time (table) > 480 $this->database->processQuery("DELETE FROM `online_users` WHERE ". time() ." - `time` > 480", array(), false); I receive this error statement: Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\wamp\www\OSREMAKE\structure\database.php on line 55 So which part requires the token? Quote Link to comment https://forums.phpfreaks.com/topic/264474-how-to-do-this-with-pdo/ Share on other sites More sharing options...
smoseley Posted June 20, 2012 Share Posted June 20, 2012 480 what? Quote Link to comment https://forums.phpfreaks.com/topic/264474-how-to-do-this-with-pdo/#findComment-1355370 Share on other sites More sharing options...
smoseley Posted June 20, 2012 Share Posted June 20, 2012 PS - try PDO::query() Quote Link to comment https://forums.phpfreaks.com/topic/264474-how-to-do-this-with-pdo/#findComment-1355371 Share on other sites More sharing options...
3raser Posted June 20, 2012 Author Share Posted June 20, 2012 Edit: Never mind, it was a simple mistake on my behalf. Quote Link to comment https://forums.phpfreaks.com/topic/264474-how-to-do-this-with-pdo/#findComment-1355381 Share on other sites More sharing options...
smoseley Posted June 20, 2012 Share Posted June 20, 2012 Just FYI - always a bad idea to "DELETE" in a web application. A better design for your system would be to have a table called `sessions` (instead of `online_users`). In sessions, store the user id, (php session id if you want) and time created. To get `online_users`, just do "SELECT * FROM `sessions` WHERE `created` > NOW() - INTERVAL 8 MINUTE;" To make it speedier, make `created` a clustered index. By storing sessions indefinitely, you can also generate reports of user activity, know when people logged in last, how often they log in, etc. And you never have to delete anything. Quote Link to comment https://forums.phpfreaks.com/topic/264474-how-to-do-this-with-pdo/#findComment-1355437 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.