Flatfile or MySQL Templates?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
mikelbring
Forum Commoner
Posts: 38
Joined: Sat Jan 05, 2008 5:28 pm

Flatfile or MySQL Templates?

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Flatfile or MySQL Templates?

Post 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.
(#10850)
mikelbring
Forum Commoner
Posts: 38
Joined: Sat Jan 05, 2008 5:28 pm

Re: Flatfile or MySQL Templates?

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Flatfile or MySQL Templates?

Post 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
Post Reply