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
https://forums.phpfreaks.com/topic/268681-fopen-vs-mysql-update-viewsviews1/
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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.