diff --git a/en/orm/database-basics.rst b/en/orm/database-basics.rst index 1a0732bbbe..380f7ada41 100644 --- a/en/orm/database-basics.rst +++ b/en/orm/database-basics.rst @@ -599,14 +599,16 @@ We then have two ways to use our datatype in our models. Overwriting the reflected schema with our custom type will enable CakePHP's database layer to automatically convert JSON data when creating queries. In your -Table's :ref:`getSchema() method ` add the +Table's :ref:`initialize() method ` add the following:: class WidgetsTable extends Table { - public function getSchema(): TableSchemaInterface + public function initialize(array $config): void { - return parent::getSchema()->setColumnType('widget_prefs', 'json'); + parent::initialize($config); + + return $this->getSchema()->setColumnType('widget_prefs', 'json'); } } diff --git a/en/orm/saving-data.rst b/en/orm/saving-data.rst index 5dd7887047..c6145ec6c4 100644 --- a/en/orm/saving-data.rst +++ b/en/orm/saving-data.rst @@ -1094,12 +1094,11 @@ column Types:: class UsersTable extends Table { - public function getSchema(): TableSchemaInterface + public function initialize(array $config): void { - $schema = parent::getSchema(); - $schema->setColumnType('preferences', 'json'); + parent::initialize($config); - return $schema; + $this->getSchema()->setColumnType('preferences', 'json'); } }