rezident/yii2-serialized-attributes-behavior

Yii2 序列化属性行为

v1.1.2 2016-03-08 08:43 UTC

This package is auto-updated.

Last update: 2024-08-29 00:12:49 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,
   			],
   		];
   	}