Symfony2: Persist roles as an array or object?

Go To StackoverFlow.com

0

Is there a reason for roles to get persisted as an extra object or should I just save them as an array in the $roles property of my User entity?

2012-04-05 16:29
by dev.pus


0

It depends. If you don't need to do special queries based on roles and/or don't mind locking yourself to a particular database vendor supporting arrays, persisting as an array will do.

2012-04-05 16:46
by Elnur Abdurrakhimov
Thank you for the quick response! Another point what would be interesting is if the creation of roles is a common task - dev.pus 2012-04-05 16:49
Unless you want to hack the security system, you'll define roles in the security.yml config file and will just persist the users' roles in an array or something else - Elnur Abdurrakhimov 2012-04-05 17:02
Ok, than I think I will progress this way. Thank you for the info : - dev.pus 2012-04-05 17:06
Ads