Jump to content

Fopen Vs Mysql Update Views=Views+1


Monkuar

Recommended Posts

Okay, I want to make a simple hit counter on my forums..

 

But the problem is, I don't want to use MYSQL. I know how to code, make it..

 

I could either update a global MYSQL UPDATE views=views+1 command with MYSQL for each refresh.

 

Or use a FOPEN command and write to a text file.

 

If the forums have 5 or 10 concurrent CONNECTIONS (Refreshing every second), which option would be the best? Seems like MYSQL Would be right? Or when does FOPEN not become suitable for this?

 

Thanks

Link to comment
Share on other sites

If you have concurrent connections at any level you might run into issues with an fopen approach. You need to make sure you implement file locking to prevent multiple scripts from accessing the file at the same time.

 

With a mysql approach you won't have to worry about the locking (assuming you do an UPDATE rather than SELECT+UPDATE combo). That will make it a bit easier to manage.

Link to comment
Share on other sites

If you have concurrent connections at any level you might run into issues with an fopen approach. You need to make sure you implement file locking to prevent multiple scripts from accessing the file at the same time.

 

With a mysql approach you won't have to worry about the locking (assuming you do an UPDATE rather than SELECT+UPDATE combo). That will make it a bit easier to manage.

 

Thanks, I think I'll be scratching the fopen thing... Doesn't seem correct on a forum to have it run each refresh.

 

I'll be looking into subqueries and see if I can sneak in a simple update query with a current select hidden somewhere :) Thanks man

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.