baibaratsky/yii2-serialized-attributes-behavior

Yii2 序列化属性行为

v1.2.0 2016-08-18 20:25 UTC

This package is auto-updated.

Last update: 2024-09-16 14:21:06 UTC


README

这个 Yii2 模型行为允许你在属性中存储数组。要附加行为,请将以下代码放入你的模型中

    public function behaviors()
   	{
   		return [
   			'serializedAttributes' => [
   				'class' => SerializedAttributes::className(),
   				
   				// Define the attributes you want to be serialized
                'attributes' => ['serializedData', 'moreSerializedData'],
                
                // Enable this option if your DB is not in UTF-8
                // (more info at http://www.jackreichert.com/2014/02/02/handling-a-php-unserialize-offset-error/)
                // 'encode' => true,
   			],
   		];
   	}