Re: [PHP] Best way to save reports, comments and suggestions welcome
Hey Robert, I have to write a kind of logging script which will keep records of how long a person used the site and its functions, so far this is what I have come up with: ... Presuming you know when they logged out or can calculate it: user_id login_time timestamp logout_time timestamp Your username values are probably nice and unique but a great big waste of space as a criteria by which to relate data. You should associate a unique integer value for each username. Theres an idea I didnt think about, thanks! Regardless of how you determine the end of the logged in time, you shouldn't track all the different sums in every entry since that's redundant. You don't even need the extra data since the database will happily allow you to perform the SUMs via queries. I have done very little SUM queries with time, can you give me a quick example or any site where i can find a few sample queries? Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to save reports, comments and suggestions welcome
On Mon, 2006-05-29 at 08:55, Ryan A wrote: Regardless of how you determine the end of the logged in time, you shouldn't track all the different sums in every entry since that's redundant. You don't even need the extra data since the database will happily allow you to perform the SUMs via queries. I have done very little SUM queries with time, can you give me a quick example or any site where i can find a few sample queries? This is basic MySQL so you should RTFM, and generally should be asking on a MySQL list :) SELECT SUM( UNIX_TIMESTAMP( logout_time ) - UNIX_TIMESTAMP( login_time ) ) AS seconds FROM some_table WHERE user_id = 1; If you have MySQL = 4.1.1 then you should probably use the TIMEDIFF() function. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to save reports, comments and suggestions welcome
Hey Rob, I have done very little SUM queries with time, can you give me a quick example or any site where i can find a few sample queries? This is basic MySQL so you should RTFM, and generally should be asking on a MySQL list :) Hehehe, true... Dont really like the MySql manual...its so much more complicated compared to the php manual. And dont really fancy joining a high traffic list like the mysql one just for a simple q like the above when there are so many experts here like you who take a moment to help guys like me out. I usually dont ask such basic q's anyway, although I admit the defination of a basic q is very different to many ppl here... SELECT SUM( UNIX_TIMESTAMP( logout_time ) - UNIX_TIMESTAMP( login_time ) ) AS seconds FROM some_table WHERE user_id = 1; If you have MySQL = 4.1.1 then you should probably use the TIMEDIFF() function. Got it, Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to save reports, comments and suggestions welcome
On Sun, 2006-05-28 at 18:49, Ryan A wrote: Hi, I have to write a kind of logging script which will keep records of how long a person used the site and its functions, so far this is what I have come up with: login_username varchar(50) as_guide - You can ignore this,its for a special func login_time timestamp logout_time timestamp this_session_inlogged_time float this_month timestamp this_year timestamp sum_total_time_inlogged varchar or float Any suggestions on changing any of the above, adding fields or changing types? I am not 100% sure of the timestamp type for most of the fields. Presuming you know when they logged out or can calculate it: user_id login_time timestamp logout_time timestamp Your username values are probably nice and unique but a great big waste of space as a criteria by which to relate data. You should associate a unique integer value for each username. Regardless of how you determine the end of the logged in time, you shouldn't track all the different sums in every entry since that's redundant. You don't even need the extra data since the database will happily allow you to perform the SUMs via queries. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php