zend framework2 - ZF2 + query entity Doctrine2 -


i'm doing query on entity, of course asked instantiate doctrine entitymanager serious question:

as instantiate entitymanager use in entity.

excuse english, using google truth xd, not meeting zf2 communities , doctrine2 in spanish.

if understood question want entitymanager inside doctrine entities, right ?

i don't think it's idea usee entitymanager within doctrine entities. this, need first instance of service manager in entity class.

by default, zend framework mvc registers initializer inject servicemanager instance, implementation of zend\servicemanager\servicelocatorinterface, class implementing zend\servicemanager\servicelocatorawareinterface

for doctrine, have make service manager available within entities. have implement servicelocatorawareinterface each entity or simpler create class implements zend\servicemanager\servicelocatorawareinterface , make entities need access service manager inherit class.

here post on how inject zf2 service manager doctrine entities

following post, entitymanager within entity :

$em = $this->getservicelocator()->get('doctrine\orm\entitymanager'); 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

html - grunt SVG to webfont -

c# - SharpSsh Command Execution -