Skip to content

Update entity_provider.rst #3116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions cookbook/security/entity_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,14 @@ Don't forget also to update your database schema:

php app/console doctrine:schema:update --force

This will create the ``acme_role`` table and a ``user_role`` that stores
the many-to-many relationship between ``acme_user`` and ``acme_role``. If
This will create the ``acme_roles`` table and a ``user_role`` that stores
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was missing before, but it should say:

and a ``user_role`` table that stores

the many-to-many relationship between ``acme_users`` and ``acme_roles``. If
you had one user linked to one role, your database might look something like
this:

.. code-block:: text

$ mysql> select * from acme_role;
$ mysql> select * from acme_roles;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought the best practice is to call the tables singular

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cordoval But the beginning of the example uses @ORM\Table(name="acme_roles"). So it must be consistent and use the same name until the end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i mean the PR should change the example overall, but i am fine with whatever, just pointing it out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about changing table names to acme_user, acme_role and acme_user_role? This way the names will be more consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always prefer plural table names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change table names to acme_users, acme_roles and acme_user_roles?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A great debate! :). My vote is for singular names. I don't know of any standard, though singular table names are used in the Doctrine documentation (http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#creating-classes-for-the-database for example).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for singular names for this is the default behaviour if you don't set the table name explicitly.

+----+-------+------------+
| id | name | role |
+----+-------+------------+
Expand Down