kayue/KayueWordpressBundle

Using createQueryBuilder with Blog id

Closed this issue · 2 comments

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.

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

Thanks Kayue.
It's working fine.