开发者

Extract MySQL Blob and add to PHP array?

开发者 https://www.devze.com 2023-01-23 18:32 出处:网络
I need to extract a list of keywords from a MySQL database. Each keyword is separated by a comma. I need to read it from the blob, then add it to the array. How would this be don开发者_StackOverflowe?

I need to extract a list of keywords from a MySQL database. Each keyword is separated by a comma. I need to read it from the blob, then add it to the array. How would this be don开发者_StackOverflowe?


First retrieve the blob from the database SELECT blob FROM tbl WHERE id=123. The PHP code used to execute the query depends on the SQL API you are using: mysql, mysqli, PDO, ...

Once you have a string containing the comma separated data use explode to split the words into an array $array = explode(',', $string).

Note that you should probably use the TEXT datatype in this case. Unlike BLOB it is collation and encoding aware. Use BLOB for pure binary data like a JPEG file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号