So here is what I ended up doing... (A good mental calisthenic!!)
1.) I created this PHP Function...
PHP Code:
function getDateTimeMicroTime(){
/**
* Create Date-Timestamp with Micro-Seconds.
*
* Written On: 2012-07-21
*
* @return String
*/
list($microSec, $timeStamp) = explode(" ", microtime());
return (date('omdhis', $timeStamp) . substr($microSec, 1));
//Ex: 20120721122038.820
}
2.) When someone visits a User's Profile, I call my PHP logVisitor() function, which performs an INSERT using the new function above.
3.) I changed the "created_on" field in my "visitor_log" table from "DATETIME" to "DECIMAL(17,3)" data-type.
4.) I created this Unique Index...
Code:
Keyname Type Cardinality Field
----------- ------- ------------ --------------
idx_u_visit UNIQUE 87 member_viewed
visitor_id
created_on
Finally, I ran a quick test and got these logged results with no errors whatsoever!!! 
Here is my output...
Code:
id member_viewed visitor_id ip hostname created_on updated_on
--- ------------- ---------- --------- --------- ------------------ ----------
815 19 0 127.0.0.1 localhost 20120721122219.080 NULL
816 19 0 127.0.0.1 localhost 20120721122219.210 NULL
817 19 0 127.0.0.1 localhost 20120721122219.340 NULL
818 19 0 127.0.0.1 localhost 20120721122219.500 NULL
819 19 0 127.0.0.1 localhost 20120721122219.620 NULL
820 19 0 127.0.0.1 localhost 20120721122219.750 NULL
821 19 0 127.0.0.1 localhost 20120721122219.900 NULL
Was all of that necessary? No.
Was it overkill? Maybe.
Did I learn some fancy new PHP and MySQL 5.0 tricks? Yes!!
Is this a better solution than I originally had? Definitely!
--------
Oh, and if I want "pretty" output, I just run a query like this...
Code:
SELECT timestamp(created_on) AS created_on
FROM visitor_log
And I get output like this in MySQL...
Code:
created_on
----------------------------------
2012-07-21 12:22:19.080000
2012-07-21 12:22:19.210000
2012-07-21 12:22:19.340000
2012-07-21 12:22:19.500000
2012-07-21 12:22:19.620000
2012-07-21 12:22:19.750000
2012-07-21 12:22:19.900000
Sincerely,
Debbie
P.S. r937 said he found it hard to believe that anyone could access a User Profile 3 times in a second. He is right, because my slow hands did it 7 times in a second.
Bookmarks