Extract MySQL Blob and add to PHP array?
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.
精彩评论