I would like to hear from you guys which do you prefer for an average site, would you go for a flat file or make the site database driven? Advantage and disadvantage one against the other?
Lastly, if your hosting is capable with mysql, would you go for database driven information for static site?
Thanks for your insight/s on this. :)
My personal web site is fundamentally static content anyway. All I really want to achieve with the scripting is to keep from having the layout, navbar, and formatting info duplicated in a whole bunch of separate files. If I decide I want to add a page, I don't want to have to edit 15 different files to put a link to it in the navbar. For that, it's all flat files on the HD, and they are simply include()ed based on query-string variables. Using a database for this would just make my life harder by making me put the HTML into the database before I read it out into the page, wheras now I can write it up in Emacs (my preferred text editor), put it in my web dir, and I'm done.
On the other hand, I also have a community site with login info, address book, message posting, etc. Trying to store all the data for this in flat files and process them to get the output for any given page would be a nightmare. Dbm files might be good enough. I don't know, because I've never tried using them.
In general, if you can just grab stuff from files without having to process it much before display, that might be the best way to go, but if there's more processing involved to find the bit you want from the data files, I'd go ahead and use MySQL.
I still run perl with flat text files, mostly because it is fast and highly portable. MySQL is really easy to use and very powerful, but I still would use flat files for smaller sites.
It has saved me a few times. The only thing I need to set up shop is a good apache server and access to perl. I could drop a flat text driven ecommerce site on a new host and have it running in 20 minutes.
Personally, for my largest site, I use a database to create the pages but I serve them as static pages.
One of the big things that may effect the choice is how often the data on the site will change (in my case probably 90% is unchanged in a given month).
Most often I use mysql, I haven't encountered many spots where it was slowing me up. More often than not it is my php as opposed to the db. I use flat files mainly on smaller projects. Littleman has the best point though, for portability you can't beat flatfiles. You just pick the whole thing up and move it. A few tweaks to the config and you're off. Db's are a little more time consuming to set up.
It just made may stand on flat files more strong. To complicate things up, I would plan to use an xml flat files and php.
But to add to my learning cup, i think i need to dig my hands into mysql too. :)
Personally, for my largest site, I use a database to create the pages but I serve them as static pages.
So you're using script to export the data into a template? Do you use this method to add pages? How do you handle navigation?
Martin,
Whenever I'm dealing with related data or data that needs to be updated on a regular basis I use a MySQL db driven page. My last few projects have been a mix of static and php driven pages.