sKunKbad Posted May 30, 2009 Share Posted May 30, 2009 Until a couple months ago, I had not even used a framework with MVC. My code was always procedural, and I'm learning more about the benefits of MVC and OOP in general. I practiced by converting my website to the Kohana framework, and about a week ago converted it to CodeIgniter. My question is, while I had not done so, I had assumed that a database driven website meant that views were essentially replaced by plain HTML that is stored in a database, but after thinking more about it, my assumption must be wrong. I can see where product content might be pulled in, through a model , and passed to the view by the controller. Is there ever an instance where a whole view would be stored in the database? Doing so would prohibit the ability to embed php into the views, so I'm guessing this isn't a proper thing to do, but I'm trying to figure out other uses for database driven content (just because I've got nothing better to do on a Friday night). Is it generally slower to have a lot of content coming from the database vs. a file? I got started thinking about this because I have a search on my website, and it is actually using file_get_contents() to look through all of my pages, and due to my website getting a little bigger, this is now starting to be quite a slow search. I thought that perhaps all of my content should belong in the database, and use MySQL to search through for matches. What is the best way to handle searching a website like mine? Quote Link to comment Share on other sites More sharing options...
trq Posted May 30, 2009 Share Posted May 30, 2009 Markup is not content. Database driven websites store content in the database, that is the entire point. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted May 30, 2009 Share Posted May 30, 2009 Markup can be content. In the last product I developed we allowed users to customize the markup on certain pages; their custom markup was saved in the database and plugged into the page where appropriate. Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted May 30, 2009 Author Share Posted May 30, 2009 Markup is not content.... Markup can be content.... So, I guess whatever works, right? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted May 30, 2009 Share Posted May 30, 2009 Just remember that the primary markup, the markup that you, the developer, controls belongs in the views if you are using MVC. Anything editable by the user belongs in the database and is inserted as appropriate. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted May 30, 2009 Share Posted May 30, 2009 As an example, the posts you've written on this forum are stored in the database, but the files that control how these are represented how they will look are stored on the file system. You could do it the other way around, or store both in the database or both in separate files on the harddisk. However, you need to consider if you actually need the functionality a RDBMS like MySQL offers. Do you need them for the template files? Well, not really. Besides. You do for the posts though. We would like to find posts that belong to a particular topic, in a particular forum, or created by a particular user, or perhaps created within a time interval. Whether you should store something as a file on the disk or in a database depends on your needs. Quote Link to comment 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.