开发者

Doctrine - getChildren() with conditions?

开发者 https://www.devze.com 2023-01-07 00:10 出处:网络
I\'m trying to write a basic plugin for the Symfony based CMS Diem. I\'m trying to list of the child pages for the current page, which I have managed to do:

I'm trying to write a basic plugin for the Symfony based CMS Diem. I'm trying to list of the child pages for the current page, which I have managed to do:

 $page = $this->getPage();
 $this->subpages = $page->getNode()->getChildren();

However, I'm unsure of the syntax to use in order to filter the child records with conditions. I would actually like to get just the records where the is_active field == 1.

I've looked at the documentation and I think I need to use the setBaseQuery method, but I could really do with an example to get me started.

Can anyone help?

Any a开发者_C百科dvice appreciated. Thanks.


Use DQL and prefetch what you need. I strongly recommend using DQL for everything accept a simple find

Or you can simple get it from the repository using the build in "magic" functions. Something like:

Doctrine::em()->getRepository('Models\SubPage')->findByIsActive(1);

Check out the documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消