skobka/yii2-json-field
最新稳定版本:v1.0.3
Composer 安装命令:
composer require skobka/yii2-json-field
包简介
Help you to define fields, that can contains json. Json in this fields would be automatically serialized and deserialized
关键字:
README 文档
README
Help you to define fields, that can contains json. Json in this fields would be automatically serialized and deserialized
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require skobka/yii2-json-field
or add
"skobka/yii2-json-field": "*"
to the require section of your composer.json file.
Usage
Once the extension is installed, simply use it in your code by :
### Product.php /** * @property object|array|null $field1 */ class Product extends AvtiveRecord { use JsonFieldTrait; public function behaviors() { return [ 'field1' => [ 'class' => JsonFieldBehavior::class, 'dataField' => 'json_field_1', // this is the name of field in db table ], ]; } } ### ProductController.php // saving $product = Product::findOne(['id' => 1]); $product->field1 = new \StdClass(); $product->field1->foo = 'bar'; $product->save(); $product = Product::findOne(['id' => 1]); print $product->field1->foo; // bar
统计信息
- 总下载量: 2.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-02-03