简体   繁体   中英

Do I have to worry about inconsistencies with multiple instances of Doctrine2 EntityManagers?

I am building a web application, and using CodeIgniter along with Doctrine2. We've managed to bootstrap Doctrine2 with the project, and working on the domain and controllers is simple and straightforward.

We want to bump up the level of abstraction by putting a Service Layer between the CodeIgniter's controllers.

Do I have to be concerned about keeping the same instance of the entity manager between all my service classes? I am wondering if this will become a problem if one of my controllers needs access to multiple service classes, and an inconsistency will form as a result of having multiple instances of EntityManagers and passing Entities from one service class to another.

Build a service locator to get hold of your entity manager. Beats passing it around all over the place.

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