简体   繁体   中英

Doctrine Many-to-many - how to access join(pivot) table?

I'm making many-to many relatioships with categories and articles. But article must have "main" category, so in oters categories "rel="canonical"" to be placed. And logically to place it in join table. In Laravel there is wery simple mechanism to do so: http://laravel.com/docs/5.0/eloquent#working-with-pivot-tables

But I read about association mapping in Doctrine: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html - and there is no info about how to access or modify that table. Is there any way to do this in Doctrine?

At the point you are adding another field to the pivot table then it is no longer just a pivot table. You will need to create an entity to access the additional column as there is no way for doctrine to know what to accommodate in an optional 3rd column of a pivot table.

If you really need to access it then you can just create a raw doctrine query to access the table directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM