Using createQueryBuilder with Blog id
Closed this issue · 2 comments
dqnguyen1989 commented
Hi Kayue,
I'm using this code to load term by it's parent id
$posts =$this->em->createQueryBuilder() ->from('KayueWordpressBundle:Taxonomy', 'tax') ->select('tax') ->leftJoin('tax.term', 'term') ->andWhere('tax.name = :tax') ->andWhere('tax.parent=:parent') ->setParameter('tax', 'category') ->setParameter('parent', $parent_id) ->getQuery()->getResult();
Can I using this code to get data from multisite blog? I want to do more work with your bundle, thanks.
kayue commented
Try to retrive entity manager via kayue_wordpress.blog.manage
service first:
$blogManager = $this->get('kayue_wordpress.blog.manager');
$em = $blogManager->findBlogById(3)->getEntityManager();
$posts = $em->createQueryBuilder(); // do your query here
dqnguyen1989 commented
Thanks Kayue.
It's working fine.