2

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 done?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.