Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions en/orm/table-objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -48,14 +48,17 @@ method::

public function initialize(array $config)
{
$this->setTable('my_table');

// Prior to 3.4.0
$this->table('my_table');
}

}

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;

Expand All @@ -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');
}
}
Expand All @@ -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');
}
}
Expand Down