dongshao8471 2011-03-25 09:30
浏览 39
已采纳

如何将一组图像保存到BLOB字段以供主题样式表调用

I was wanting to save my site themes to my database but I was wondering if I can just store all the files and information I need in one row. I didn't want to make 100 rows each with image content.

So for example in 1 row I would have

theme_name
theme_date
theme_data
theme_css_data
theme_js_data
theme_images

etc..

I read that it is better to save images/documents with a BLOB to a database as it takes up less space than a physical disk. But will this be a pain when backing up the database?

Which is a commonly used way to save images,word documents, pds, excel that are part of a theme?

  • 写回答

2条回答 默认 最新

  • duankuixi1930 2011-03-25 09:46
    关注

    you can save the whole theme in one single field, but how are you gonna use it later? if you need just to archive unused theme then you can pack it in database, but if you want to use files you should do 2 tables:

    1. themes with fields:

      • theme_id
      • theme_name
      • theme_date
      • theme_data (if you don't want to query by this data
    2. theme_files

      • theme_file_id
      • theme_id - used to connect the file to a theme
      • theme_file_keyname - you can use this if you want to query certain files regardless of their file name. example - index (could be index.htm or index.html), stars_image (file could be stars.gif or stars.png)
      • theme_file_name (which might contain relative path. Ex: "images/background/top.gif")
      • theme_file_type (or mime type)

    in this case it is better to have one row per each file because when you query the database you want to extract one single file you could use it's theme_file_keyname or theme_file_name. You don't always need all files of the theme

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突