12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?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);
- }
- }
|