Page 1 of 1

Flatfile or MySQL Templates?

Posted: Mon Oct 06, 2008 8:42 pm
by mikelbring
I am coding the framework for my new site and in the past ive always used a mysql template system. But I am considering using flatfiles but not sure on this one. Currently what I do is select all templates in the global and put them each into a variable so then I run my fetch_template function which will eval the template variable. Why do I select them all at once, because if I run the same query so much then mysql should cache it.

But I want to know if my system would be faster to use flatfiles and if I went this route should I simply do includes or actually readfile? Thanks

Re: Flatfile or MySQL Templates?

Posted: Mon Oct 06, 2008 10:14 pm
by Christopher
Honestly, I would recommend defining an interface to the template system and programming to the interface. Then behind the interface code both flat file and database Data Sources. They are both pretty easy to write. Then depending on need, use one or the other.

Re: Flatfile or MySQL Templates?

Posted: Mon Oct 06, 2008 10:22 pm
by mikelbring
I kinda did that already. In my old admin panel I had a edit template interface and it would save to flatfile and mysql and I would pull from flatfiles but I ended up scratching the flatfile idea and going with all mysql but now Im back to the same idea. The thing is id rather edit my template and upload instead edit and paste it into the template. But I might do both I don't know yet. Looking around for ideas. Im new to classes and OO haven't got use to the whole MVC type of system yet. The last few years I did normal php but now im expanding it.

Re: Flatfile or MySQL Templates?

Posted: Tue Oct 07, 2008 1:03 am
by josh
Id store the templates on the disk and the metadata in a database, accessing the metadata thru an interface that also handled manual directory based overrides, kind of like .htaccess does for apache, ideally you'd want all your metadata mostly in one place tho, and not half in the database and half scattered through a directory tree