在MySQL中存储HTML代码 [英] Storing html code in mysql

查看:1691
本文介绍了在MySQL中存储HTML代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是场景,

我在应用程序中使用MVC(Model,View,Controller)结构.我正在使用的平台是 Cake PHP ,而我的数据库位于mysql中.

我允许用户在页面的某个元素(主要是div元素/容器)中进行更改.我将通过使用Ajax和JQuery达到目标,但是主要问题是保存更改后的内容.

我虽然已经将整个html代码保存在数据库中,但是我不确定它的检索部分..

因此,就我应该使用的审批方式而言,需要就此主题提出建议.

如果我应该使用数据库来保存内容,则对于这种字段,最好使用两种数据类型(文本或拇指blob)中的哪一种.

Here is the scenario,

I am using MVC(Model,View,Controller) structure in my application.The platform which I am using is Cake PHP and my database is in mysql.

I am allowing the user to make changes in an element of the page,mainly div element/container.I will achieve the goal by using Ajax and JQuery,but the main question is of saving the changed content.

I have though of saving the entire html code in the database but I am not quiet sure about the retreiving part of it..

So need suggestion on this topic,regarding the way of appoarch that I should use.

If I should use database for saving the contents then which of the two datatype(text or thumbblob) is better for such a field.

Any Help would be highly appreciated.

推荐答案

由于所有HTML都是文本,因此我认为使用保留用于二进制信息的数据类型没有任何好处.甚至图像也会使用基于文本的格式以http/https发送.将其存储为二进制文件的唯一好处是,您将使用较少的空间,但是您还必须对二进制信息进行编码和解码,以便在http/https中使用.总的来说,我认为您不应该为此烦恼.
Since all HTML is text, I see no advantage to using a datatype reserved for binary information. Even images are sent using text based formats in http/https. The only advantage to storing it in binary is that you will use less space, but you will also have to encode and decode the binary information for use in http/https. Overall, it is not worth the hassle you will encounter, in my opinion.


这篇关于在MySQL中存储HTML代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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