doctrine2 - What is the best way to use doctrine entity manager in application? Can be many doctrine entity manager instances? -


i write mini php framework. not understand how deal doctrine 2 entity manager.

1) can many doctrine entity manager instances? can create new instance in view, in controller, , in other classes of program?

for example, conn.php contains logics how connect database, , create entity manager instance $em.

class some1 {     private $em;      public function __construct() {       require 'conn.php'       $this->em = $em;     } }  class some2 {     private $em;      public function __construct() {       require 'conn.php'       $this->em = $em;     } }  class some13 {     private $em;      public function __construct() {       require 'conn.php'       $this->em = $em;     } } 

2) shall create 1 wrapping class, , make em static variable in it?


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -