BLOB to String or image / PHP or sql


BLOB to String or image / PHP or sql

我有一个数组,它给了我一个三维图像斑点。

但我需要图像,我尝试使用 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">'