tags:

views:

26

answers:

1

I am creating a custom CMS in PHP (written from scratch) and want to know whether I should store user created pages as files or in a MySQL database.

The content is all HTML code, at least for now.

I cannot decide which to do as writing files with php seems like a security risk, and retrieving file contents from MySQL on every page load feels wrong (and could be a performance issue?).

I also have custom pages coded by me for a blog, etc. These contain PHP code but do not need to be modified by the user. Currently I am planning to store these as php files as its easier to upload them and edit them like that, but they could also be stored in MySQL.

I would greatly appreciate any help on what the right thing to do is, or at least what you would do.

+2  A: 

You'd be better off storing content in the database. Note that you store content, not the entire HTML page (otherwise, you're not really building a content management system).

It's quite normal to do a database query on every page view; indeed it is typical for web apps to do more than 5 and sometimes as many as 20 database queries on every page view, and I would guess that stackoverflow.com would probably fit into that range.

MySQL is fast enough.

thomasrutter