我有一个数组,可以在第 3 维给我一个图像 block 。
但我需要图像,我尝试使用 SQL
<?php $global = \Database::getInstance()->execute('SELECT CONVERT(VarChar(40), image)
FROM mm_product2
WHERE id = '.$referenzen['id'])->fetchAllAssoc(); ?>
<?php print_r($global);?>
它显示这个错误:
Fatal error: Uncaught exception Exception with message Query error:
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near 'VarChar(40),
image) FROM mm_product2 WHERE id = 23' at line 1 (SELECT CONVERT(VarChar(40),
image) FROM mm_product2 WHERE id = 23
没有表达式它可以工作,但我像在标准数组中一样再次获得该 blob 值:
[image] => 85392c33-a0f7-11e4-acb9-08606e695836 )
我可以知道如何在 PHP 中或仅在 SQL 中转换该值吗??
最佳答案
使用mysql查询获取变量中的blob数据,然后使用这个
'<img src="data:image/jpeg;base64,' . base64_encode($image) . '" width="200" height="200">'
关于php - BLOB 到字符串或图像/PHP 或 sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28087987/