简体   繁体   中英

Entity relations without second entity (value from array)

first I appologize if the topic may confuse you. I try to explain my question. In an application there are a lot of information which are too small to build an own entity for that. Some examples gender or status.

Is there a recommended way to do that or is it still an entity with two to five value in a table?

What I need is the standard behaviour in forms (selectbox) and show the value by an id.

I would certainly create these as entities!

You may feel it to be overkill, especially when you are just populating select boxes. However, it will be required to create the correct entity relationships such as $user->getGender()->getName() etc I doubt that the Gender options will change but it will be a reusable class for all your other projects.

Remember that Doctrine and other popular ORMs will proxy access to the object so it will be called in a lazy manner.

You could also use a "view helper" of some description that directly queries the database for the values you want and displays the select options accordingly, while you are still using your new entities elsewhere.

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