Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/160242-database-driven-websites-and-mvc/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.