How can I get image data string from mysql db that has blob images? Thanks.
如何从具有blob图像的mysql db获取图像数据字符串?谢谢。
2 个解决方案
#1
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.
假设您正在使用Symfony附带的默认ORM(Propel),$ your_object-> getImage()*应该返回您存储在数据库中的任何blob值。
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
*假设'image'是数据库/ schema.yml中的字段名称
#2
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.
是的sjobe的$ x-> getImage()足以获得blob内容。
#1
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.
假设您正在使用Symfony附带的默认ORM(Propel),$ your_object-> getImage()*应该返回您存储在数据库中的任何blob值。
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
*假设'image'是数据库/ schema.yml中的字段名称
#2
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.
是的sjobe的$ x-> getImage()足以获得blob内容。