RE: [PHP-DB] Getting rows where column has changed?
| From: | John W. Holmes | Date: | Sun, 27 Oct 2002 14:03:40 +0000 |
| Subject: | RE: [PHP-DB] Getting rows where column has changed? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22728@lists.php.net to get a copy of this message | ||
> I'm trying to make a page to help in detecting people using automatic
> refresher programs. In the table that stores user info, there is a
> column called "lastseen" which says when the user was last seen. I'm
> trying to:
> 1. Select all lastseen colmns that are less than 5 minutes old
> 2. Wait 2 seconds
> 3. Select lastseen columns that have changed since step 1, and display
> that info
> Any ideas on how to do this? Is it even possible? Thanks...
Temp tables would probably work great here... I'm assuming mysql, but
the logic should work with any db.
<?
//untested code:
$result = mysql_query("CREATE TEMPORARY TABLE temp (PRIMARY KEY (id))
SELECT id, lastseen FROM table WHERE lastseen > NOW() - INTERVAL 5
MINUTE");
sleep(2);
$result = mysql_query("SELECT table.* FROM table, temp WHERE table.id =
temp.id AND table.lastseen != temp.lastseen");
Then parse the results of the second query and it should give you those
rows that have changed in 2 seconds.
---John Holmes...