Jump to content

Recommended Posts

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?  :shrug:

Link to comment
https://forums.phpfreaks.com/topic/264474-how-to-do-this-with-pdo/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.