开发者

How can I write a DQL for these entities?

I have entities 开发者_如何学Goseen as DB screenshot:

You can see the screenshot here-> http://imageshack.us/photo/my-images/830/asdsasda.jpg/

I want to bring an object array of TnModuleItem by giving a TnRegion parameter.

How can i write in DQL to bring this query.

Edit: I want to write a model like this:

public function get_module_items_by_region_id($region_id){
// code comes here
return $tnModuleItemsObj //TnModuleItemsObject
}


And if you try something like:

 <?php
 public function get_module_items_by_region_id($region_id){
     $query = $em->createQuery('SELECT i FROM \namespace\TnRegionModuleItem as i WHERE i.regionId = :region_id');
     $query->setParameter('region_id', $region_id)

     return $query->getResult()
 }     

 ?>

Offcourse you should get your entitymanager somewhere from and put in the variable $em, in my case I use the Bisna 'glue' for Zend Framework and I retrieve it by the Zend_Registry but that could be different in your case.

With the result value you can foreach your module items and every element is a tnModuleItem object.

Good luck!


OK. I solved problem with this:

            $query = $this->em->createQuery('SELECT rmi, mi FROM TnRegionModuleItem rmi JOIN rmi.moduleItem mi JOIN rmi.pageRegion pr JOIN pr.region r WHERE r.id = :regionid');

must select a root entity.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜