RE: Last visitors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Theres something wrong coz its not working as expected...
> I followed instructions and created a table like this:
>
>
> CREATE TABLE test_last_visitors (
>   profile_id int(10) default NULL,
>   user_id int(10) default NULL,
>   ttimestamp timestamp(14) NOT NULL) TYPE=MyISAM;
>
> then I ran this 5 times: (logic being: test with 5, if it works go
> with 10 or more) :-)
> insert into `test_last_visitors` values(1,1,now());
>
> then from my php script (test_last_visitors.php) I ran this test SQL:
> $SQL = "UPDATE test_last_visitors SET profile_id=".$profile_id.",
> user_id=user_id+1,
> ttimestamp=now() WHERE profile_id=1 ORDER BY ttimestamp ASC LIMIT 1";
>
>
> The first 5 times it works perfectly, then after that it updates only
> the latest record over and over again :-(
> I tried playing with the ASC and DESC, MIN and MAX....no joy.
>
> Any idea whats wrong?

/*
The following works for me.

UPDATE test_last_visitors
SET user_id=user_id+1
WHERE profile_id=1
ORDER BY ttimestamp LIMIT 1;

You don't have to explicitly update the timestamp column. It will do this
automatically. This will rotate through the five rows. This may have failed
in your test because if you executed this in a script and all of the sql
statements occurred in the same second, you would probably see the behavior
that you described.
*/

Keep running the same UPDATE query a few times and see that it only updates
the top record, it leaves all the others even though the others timestamps
are lower... atleast thats whats happening to me :-(

Thanks,
-Ryan




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 4/18/2005

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux