将图像存储在mysql数据库中 [英] Storing Images in a mysql database

查看:103
本文介绍了将图像存储在mysql数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在数据库中唯一存储和映像名称的最佳方法是,假设两个人具有相同的映像名称,或者同一用户上载相同的映像两次.我该如何管理这种场景,以便当我想要执行诸如更新,删除之类的操作时,我最终不会删除这两个图像或全部图像.我的数据库是MySQL.

what is the best way to uniquely store and image name in a DB, assuming two persons have the same image name, or the same user uploads the same image twice. How can i manage scenerios like this so that when i want perform operations like updating, deleting, i don't end up deleting both images or all. My DB is MySQL.

编辑-好的,现在,由于某种原因,我为所有在localhost上运行的图像生成了唯一的时间戳记,但是当我将其联机时它不起作用,则无法删除它,但是它可以脱机工作很好.

谢谢 @cybeormin

Thank you @cybeormin

推荐答案

在任何表中,我都会推荐一个ID列,该列为Auto Increment并设置为Primary Field.这样,即使用户有两个相同名称的图像,所有行都是唯一的.

In any table I would recomend an ID column that that is Auto Increment and set to the Primary Field. That way all rows are unique despite a user have two images of the same name.

这篇关于将图像存储在mysql数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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