Help Reading Binary Image Data from SQL Server into PHP

女生的网名这么多〃 提交于 2019-12-06 09:25:19

No experience with SQLServer but I did work with BLOBs in MySQL. You have two options,

  1. Escape binary data so it works in SQL query. You can do this by using addslashes() before data is inserted and stripslashes() when it comes back.

  2. Using hex syntax of the SQL query.

Not sure if it's standard SQL but in MySQL, you can read BLOB into hex like this,

 select hex(image) from table;

You can write binary data as hex in SQL like X'1234ABCD'.

PHP provides hex2bin/bin2hex so you can convert easily.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!