symfony - Doctrine querybuilder where element is child of a doctrine nested set tree parent -


I want to create a query builder that brings back the given element to their parents to a certain point is.

Duplication is not right when using parent or root because there are several levels.

So far I have this code:

  return = $ this -> ('Parent =? 2') -; CreateBuilder ('o') - & gt; Left Zone ('O. categories', 'C') - & gt; Left zone ('c.parent', 'parent') - & gt; & Gt; Or where ('parent.parent =? 2') - & gt; Setpayter (2, $ origin) - & gt; GetQuery () - & gt; GetResult ();  

Of course, if parents are not their original parents and they are not parents then it does not work anymore.

How can I do this?

I have finished the following work

  / ** * Product Repository * * This class was originally created by ORM, add your own custom * repository methods * / Abstract category extended to HasCategoryRepository EntityRepository {/ ** * Return query builder * / abstract function getExplorerQueryBuilder (); / ** * Filter on the content, which is related to the category '* * @ Ultimate Object Category $ Object Caribbean * @Treauf Exception * @ Return / Principle ORM \ QueryBuilder * / Public FunctionByTopCategorycutBuilder ($ objectCategory) {$ ObjectCategoryRepository = $ This- & gt; _em- & gt; Received Resository ('AppBundle: Core \ Object Category'); If (Object Cubation $ object object) $ objectCategory = $ objectCategoryRepository-> Search On (array ('slug' => Object object category);); If (! $ Item range) throw new exception ("La Catagory N.A. pass etre Trui."); $ QueryBuilder = $ this- & gt; GetExplorerQueryBuilder (); $ Categories = array_merge (Ar ($ object Caribbean), $ object Caribbean repository-> Children ($ Object Carriage)); $ CategoriesIds = array_map (function (basecrack class $ range) {return $ range-> getid ();}, $ ranges); $ QueryBuilder = $ queryBuilder - & gt; ('C.id', $ categoriesIds); and where ($- >-- createQuerybuilder ('object') -> expr () - & gt; $ QueryBuilder returned; }}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -