php symfony从mysql获取blob图像数据

发布于 2024-07-18 05:58:58 字数 46 浏览 3 评论 0原文

如何从具有 blob 图像的 mysql 数据库获取图像数据字符串? 谢谢。

How can I get image data string from mysql db that has blob images? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴情换悲伤 2024-07-25 05:58:58

假设您使用 Symfony 附带的默认 ORM (Propel),$your_object->getImage()* 应该返回您存储在数据库中的任何 blob 值。

您可能已经知道这一点,并且这不是一个选项,但是您是否考虑过将图像存储在目录中并使用数据库存储图像的路径?

*假设'image'是database/schema.yml中的字段名称

Assuming that you're using the default ORM (Propel) that comes with Symfony, $your_object->getImage()* should return whatever blob value you stored in the database.

You might already know this and it's not an option, but have you considered storing the images in a directory and using the database to store the path to the images ?

*Assuming 'image' is the field name in the database/schema.yml

作妖 2024-07-25 05:58:58

关于将图像存储在数据库与文件系统中总是存在争论。

将它们存储在数据库中更安全(如果您需要安全地访问它们),但通常您需要包装器来读取它们并将其显示在标签中(如果您这样做)。

有很多优点和缺点......取决于您的需求哪个更好。

是的,sjobe 的 $x->getImage() 足以获取 blob 内容。

There is always flamewar about storing images in a database vs. filesystem.

Storing them in a database is more secure (if you need to secure access to them) but usually you need wrapper to read and display them in tag (if you do it).

There's a lot of pros and cons... Depends on your needs what is better.

and yes sjobe's $x->getImage() would be enough to get a blob content.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文