Post by meowmeowcastle.com » Sat Nov 21, 2015 9:42 am

I'm using opencart 2.1 and create two new field on customer registration: birthday and current year. I find out that both field is stored on the customer table as an text array under "custom" column. The data field 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.

Image
Asian Beauty in the US


User avatar
New member

Posts

Joined
Wed Nov 18, 2015 3:03 pm
Location - Boston, MA
Who is online

Users browsing this forum: No registered users and 31 guests