Results 1 to 4 of 4
Dec 17, 2009, 08:25 #1
MYSQL On Duplicate (Exclusion Clause?)PHP Code:
$update = '('.$site_id.',"'.$user_id.'","'.$online_ip.'",'.$time.')';
$sql_online = 'INSERT INTO `user_online` (site_id, user_id, online_ip, online_timestamp) VALUES '.$update.' ON DUPLICATE KEY UPDATE online_timestamp=VALUES(online_timestamp)';
online_ip - Primary Key
site_id - Unique Key
As you can see the above works well as a Users Currently Online, as every time the user visits a page it inserts their information, or updates the timestamp.
The problem I have is that two websites useing same database, with the difference site_id value.
Ive noticed that If i go to Site 1, then Site 2. Only Site 1 is visitor is counted.
Is their a way around this obstacle, a conditional clause on site_id ?
Dec 17, 2009, 08:34 #2
Make your primary key: online_ip, site_idGuido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget
Dec 20, 2009, 08:48 #3
That seems to do the trick, thanks for your time!
It passed my mind that you could have two primary keys.
Dec 20, 2009, 12:55 #4
- Join Date
- Jul 2002
- Toronto, Canada
- 63 Post(s)
- 3 Thread(s)