Monkuar Posted September 23, 2012 Share Posted September 23, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/268681-fopen-vs-mysql-update-viewsviews1/ Share on other sites More sharing options...
kicken Posted September 23, 2012 Share Posted September 23, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268681-fopen-vs-mysql-update-viewsviews1/#findComment-1380182 Share on other sites More sharing options...
Monkuar Posted September 23, 2012 Author Share Posted September 23, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/268681-fopen-vs-mysql-update-viewsviews1/#findComment-1380185 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.