简体   繁体   English

处理博客的内容-数据库

[英]Handling content for Blog - Database

let's say i want to create a blog and are then going to handle text, links, images and so on, but how would i save this into a database? 假设我想创建一个博客,然后要处理文本,链接,图像等,但是我将如何保存到数据库中呢?

Here's a random example. 这是一个随机的例子。

Example - Text: 示例-文字:

Hello, this is my blog. 您好,这是我的博客。 Check out this site! 看看这个网站! Cakes: 蛋糕:

  1. Cookie 曲奇饼
  2. Muffin 松饼

Example - HTML: 示例-HTML:

<p>Hello, this is my blog.</p>
<p>Check out this <a href="google.com">site</a>!</p>
<p>Cakes:</p>

<ol>
  <li>Cookie</li>
  <li>Muffin</a>
</ol>

Would i just save the HTML into the database or how should i handle this? 我只是将HTML保存到数据库中还是应该如何处理? Can't see any other way. 看不到其他方式。

If all your post are going to have the same sections you could save just data. 如果您的所有帖子都有相同的部分,则可以只保存数据。 For example, if your blog is about cooking, so you can save only list of ingredients, steps to prepare, description, name, etc. But if it is about different topics and you can not identify a pattern, so you will need to save the html to database. 例如,如果您的博客是关于烹饪的,那么您只能保存配料列表,准备步骤,描述,名称等。但是,如果是关于不同主题且您无法识别模式,则需要保存HTML到数据库。

Yes, you save the whole HTML into database, for images either you save the link or using server side language you just save path for your image and save the image in a particular folder then add the path into database. 是的,您将整个HTML保存到数据库中,对于图像,您可以保存链接或使用服务器端语言,只需保存图像的路径并将图像保存在特定的文件夹中,然后将路径添加到数据库中即可。 Example you a folder named images in you root folder of server. 例如,您在服务器的根文件夹中有一个名为images文件夹。 then you save <img src="images/imagename.jpg" alt="image"> . 然后保存<img src="images/imagename.jpg" alt="image">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM