sam-it / yii2-jsonbehavior
高级 AR JSON 支持
v2.0.0
2020-06-01 11:26 UTC
Requires
- php: > 7.4
- ext-json: *
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- phpunit/phpunit: ^9.1
- squizlabs/php_codesniffer: ^3.5
- yiisoft/yii2: ^2.0
- dev-master
- v2.0.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/node-fetch-2.6.7
- dev-dependabot/npm_and_yarn/semantic-release-19.0.3
- dev-dependabot/npm_and_yarn/minimist-1.2.6
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/glob-parent-5.1.2
- dev-dependabot/npm_and_yarn/normalize-url-5.3.1
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/handlebars-4.7.7
- dev-dependabot/npm_and_yarn/y18n-4.0.1
- dev-dependabot/npm_and_yarn/ini-1.3.8
This package is auto-updated.
Last update: 2024-08-25 17:59:32 UTC
README
Yii2 JsonBehavior
在 Yii2 中处理 JSON 字段
此行为为在 Yii AR 模型中处理 JSON 数据提供了高级支持。
像普通字段一样使用 JSON 字段
考虑一个具有 data
属性的模型,该属性以 JSON 格式存储。
public function behaviors() {
return [
['class' => JsonBehavior::class, 'jsonAttributes' => ['data']]
];
}
// Examples:
$model = new Model();
$model->a = "test"; // If attribute 'a' does not exist this is stored inside the data.
$model->a['b'] = 'c']; // Nested arrays are supported.
$model->data = ['x' => 'y']; // Assigning directly is supported.