I'm using opencart 2.1 and one of the field on the customer table is an text array. The data field (named custom, type text) look like this:
{"2":"2015","1":"2000-11-19"}
Basically, the 1st part is a birthday (not allow null), and the second part is today year (allow null). It was saved to the database using serialize($arr)
I need a query to get the data based on the "birthday" part. Basically, it's something like this:
SELECT * FROM CUSTOMER WHERE MONTH(custom.1) = MONTH(NOW()) AND DAY(custom.2) = DAY(NOW())
I don't know how to refer to part 1 or part 2 of the custom field. If I can get the query to work, I can bring it back to php and use $arr = unserialize($arr) to fetch it into an array and use it.
Also, later on, I would need to update the part 2 of the custom field (aka, the "this year" part. It can be null, or last year, and need to be update to this year). How could I do that and still keep the part 1 (aka, birthday) the same?
Does anybody know how to do this?
Thanks.
LIKEto look for unique parts -- not very reliable. It is not, generally, good practice to store data in this fashion because, as you have experienced, it is difficult to include in queries. I know you didn't set it up that way, but you're learning the lesson from someone else's mistake.