General Considerations for Click Counter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Death
Forum Newbie
Posts: 17
Joined: Tue Apr 19, 2005 11:52 am

General Considerations for Click Counter

Post by Death »

Hi guys,

I want to count the hits I'm sending to various links. It's pretty easy to do but I'm still not sure about something. I'm presumming it would be faster to store the counts in a database rather than a flat file, does that mean I have to make the connection, access the data, increment it, then close the connection every single time someone clicks a link I am counting ?

I am a pro at C(++) so programming comes easy to me but I'm a little rusty on database stuff.

It just seems like a lot of overhead to maintain and increment some integers.

So am I on the right track here ?

Any guidence would be appreciated.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that's the typical way.. Connecting to a database is rather simple for most protocols. For instance, the average phpbb page makes one database connection and 10 or more queries before completing the page.

Unless you are doing very large hit counts, don't worry about it too much. You can use connection pooling and/or persistant connections to offset the connection time if you feel it's too high...
Post Reply