1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace yii\db\mysql;
- use yii\db\ExpressionInterface;
- use yii\db\JsonExpression;
- class ColumnSchema extends \yii\db\ColumnSchema
- {
-
- public $disableJsonSupport = false;
-
- public function dbTypecast($value)
- {
- if ($value === null) {
- return $value;
- }
- if ($value instanceof ExpressionInterface) {
- return $value;
- }
- if (!$this->disableJsonSupport && $this->dbType === Schema::TYPE_JSON) {
- return new JsonExpression($value, $this->type);
- }
- return $this->typecast($value);
- }
-
- public function phpTypecast($value)
- {
- if ($value === null) {
- return null;
- }
- if (!$this->disableJsonSupport && $this->type === Schema::TYPE_JSON) {
- return json_decode($value, true);
- }
- return parent::phpTypecast($value);
- }
- }
|