PHP:唯一标识符
我将刚刚加载的图像的 id 'concat' 到 mysql 用户记录中,如下所示。
Userid … Photos_ids
12 1 2 5 7
而且这个photo_id应该是唯一的。 (创建唯一的文件名)。现在我从内存缓存中获取当前的最后一个 id。但据我了解,这并不是真正安全。
难道还有其他的想法吗? (我不会将任何其他记录添加到数据库中,因此只有当我为此添加一些其他特殊表时才能使用主键......这不是一个好主意)。
I ‘concat’ an id of just loaded image into mysql user record like this.
Userid … Photos_ids
12 1 2 5 7
And this photo_id should be unique. (To create unique file name). Now I get a current last id from memcache. But it's not really safely, as far as I understand.
It there any other ideas? (I do not add any other records into db, so PRIMARY KEY can be used only if I'd add some else special table for this... It's not a good idea).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么不使用 PHP 的 uniqid 函数?
Why not use PHP's uniqid function?
有两个表,将 id 列设为主键,并将 自动递增
示例:
在示例中,插入新图片会自动将 id 加 1。
Have two tables, make the id column the Primary Key and Auto Increment
Example:
In the example, INSERTing a new pictures would automatically increase the id by 1.
有一个单独的图像表。
Have a separate table for images.