user991041
user991041

Reputation: 91

Search in serialized array

I want to do search query in serialized array that is stored in my database. Data look like this:

a:4:{i:0;s:16:"2013-03-24 15:00";i:1;s:16:"2013-03-24 11:00";i:2;s:16:"2013-03-17 15:00";i:3;s:16:"2013-03-17 11:00";}

Field name is dates. I want to search dates like '2013-03-24' but no success.

Thanks.

Upvotes: 0

Views: 121

Answers (1)

Your Common Sense
Your Common Sense

Reputation: 157839

Do not store serialized arrays in database.

This is the only answer to your question.
Create a table to hold all that data you stored in a serialized form, and then store each value in a distinct cell.

Then you will be able to make a regular sql query like

SELECT * FROM table WHERE date1 = '2013-03-24 15:00'

Upvotes: 1

Related Questions