baibaratsky / yii2-serialized-attributes-behavior

ActiveRecord behavior that allows you to store arrays in attributes
Other
11 stars 7 forks source link

serialized data in database #1

Closed truth4oll closed 9 years ago

truth4oll commented 9 years ago

Save serialized data in database through base64_encode, and get through base64_decode. It helps avoid popular error with offset

baibaratsky commented 9 years ago

Hi! Could you provide more info on this error. I use this way to store serialized data for about 5 years without any problems.

baibaratsky commented 9 years ago

Oh, I think I know what you mean. The problem appears when you use non-UTF8 encoding in your database. Ok, I'll add this feature soon.

truth4oll commented 9 years ago

for example http://php.net/manual/en/function.serialize.php#47509

baibaratsky commented 9 years ago

Your example is not about DB, it’s on submission of serialized data with HTML forms. Here is more related one: http://www.jackreichert.com/2014/02/02/handling-a-php-unserialize-offset-error/

baibaratsky commented 9 years ago

As I said, there’s no problem when you use UTF8 in the DB.