Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP and flat files vs. MySQL

where is the limit and when to switch

4:39 am on Mar 9, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:June 2, 2006
votes: 2

I have a simple code that calls a flat file, checks lines, and if it does not find an entry, it appends it. I use it to write down the keywords. Every time a visitor comes, the file is opened, checked, written in if there was no keyword, and closed.

So far, depending on the site, the flat file has gone up to close to 1 MB. I'm just thinking that opening a file and checking so many lines from top to bottom is not so smart.

I'm kind of set to switch to MySQL, but I'm still curious about your experience with flat files vs. MySQL (in PHP environment).
I know that the server performance is No.1, but still there must be more to it that drives web developers in making their decisions between flat file and database.

With the move to MySQL, I hope to get faster read/write, and to be able to count number of searches for keywords that are already in the database.

Any right/wrongs?


2:03 pm on Mar 9, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 26, 2004
votes: 0

Not only are flat files slow for large amounts of data they don't allow you to analyse the data and sort it so easily.

Mysql would be easy to use in this case.

2:10 pm on Mar 9, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 9, 2003
votes: 0

As you say, MySQL would allow you to keep track of how many times each keyword was used, which seems like it would be useful data to me.