CMS:将自定义页面存储为文件或MySQL数据库? [英] CMS: store custom pages as files or in MySQL database?

查看:178
本文介绍了CMS:将自定义页面存储为文件或MySQL数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP(从头开始创建)中创建一个自定义CMS,并想知道我应该将用户创建的页面存储为文件还是存储在MySQL数据库中。

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.

内容是所有的HTML代码,至少现在。

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

我无法决定使用php编写文件时做什么似乎是一个安全风险,并从MySQL检索文件内容在每个页面加载感觉错误(可能是一个性能问题?)。

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?).

我也有自己的网页编码的博客等等这些包含PHP代码,不需要由用户修改。目前我计划将它们存储为php文件,因为它更容易上传和编辑它们,但它们也可以存储在MySQL。

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.

我会非常感谢

推荐答案

你会得到更好的效果在数据库中存储内容。请注意,您存储的是内容,而不是整个HTML页面(否则,您不是真正构建了内容管理系统)。

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).

使用纯文件实现它,然后你必须发明一个文件格式来存储结构化数据,你必须找出如何使它快,担心数据完整性和竞争条件,等等。有了一个数据库,你得到了所有这些已经为你做了,它做得很好,快速。

If you implemented it using plain files then you'd have to invent a file format for storing your structured data in, you'd have to figure out how to make it fast, worry about data integrity and race conditions, and more. With a database you get all this already done for you and it's done well and fast.

在每个页面视图进行数据库查询是很正常的;实际上,网络应用程序通常在每个页面视图上执行多于5个和多达30个数据库查询,我猜想stackoverflow.com可能适合该范围。

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 up to 30 database queries on every page view, and I would guess that stackoverflow.com would probably fit into that range.

MySQL是足够快的。

MySQL is fast enough.

这篇关于CMS:将自定义页面存储为文件或MySQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆