diff --git a/en/orm/table-objects.rst b/en/orm/table-objects.rst index d1564b2178..600f269afd 100644 --- a/en/orm/table-objects.rst +++ b/en/orm/table-objects.rst @@ -36,7 +36,7 @@ Note that we did not tell the ORM which table to use for our class. By convention table objects will use a table that matches the lower cased and underscored version of the class name. In the above example the ``articles`` table will be used. If our table class was named ``BlogPosts`` your table should -be named ``blog_posts``. You can specify the table to using the ``table()`` +be named ``blog_posts``. You can specify the table to using the ``setTable()`` method:: namespace App\Model\Table; @@ -48,6 +48,9 @@ method:: public function initialize(array $config) { + $this->setTable('my_table'); + + // Prior to 3.4.0 $this->table('my_table'); } @@ -55,7 +58,7 @@ method:: No inflection conventions will be applied when specifying a table. By convention the ORM also expects each table to have a primary key with the name of ``id``. -If you need to modify this you can use the ``primaryKey()`` method:: +If you need to modify this you can use the ``setPrimaryKey()`` method:: namespace App\Model\Table; @@ -65,6 +68,9 @@ If you need to modify this you can use the ``primaryKey()`` method:: { public function initialize(array $config) { + $this->setPrimaryKey('my_id'); + + // Prior to 3.4.0 $this->primaryKey('my_id'); } } @@ -76,12 +82,15 @@ By default table objects use an entity class based on naming conventions. For example if your table class is called ``ArticlesTable`` the entity would be ``Article``. If the table class was ``PurchaseOrdersTable`` the entity would be ``PurchaseOrder``. If however, you want to use an entity that doesn't follow the -conventions you can use the ``entityClass()`` method to change things up:: +conventions you can use the ``setEntityClass()`` method to change things up:: class PurchaseOrdersTable extends Table { public function initialize(array $config) { + $this->setEntityClass('App\Model\Entity\PO'); + + // Prior to 3.4.0 $this->entityClass('App\Model\Entity\PO'); } }