学说加入DQL [英] Doctrine Join DQL

查看:110
本文介绍了学说加入DQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个特定ID的2个表之间进行联接.目前,我有这个DQL:

I's like to do a join between 2 tables on a specific ID. At the moment, I have this DQL:

$q = Doctrine_Query::create()
         ->select('e.*, i.itemName, i.itemtypeId')
         ->from('Model_EventItem e')
         ->leftJoin('Model_Item i ON e.itemId = i.itemId')
         ->where('e.eventitemId = ?', $event->eventId)
         ->orderBy('i.itemName ASC');

结果是空的,尽管我的eventId有一个值...您能帮我吗?我在某处有关于DQL-join的教程吗?在Doctrine文档的帮助下,我做错了.

The result is empty, although my eventId has a value ... Can you help me please? I there somewhere a tutorial on DQL-joins? I don't get it right with the help of the Doctrine documentation.

谢谢!

PS我的学说与Zend Framework结合使用.

PS I have doctrine working in combination with Zend Framework.

推荐答案

您需要向模型添加一个关系并使用该关系联接表

you need add a relation to the model and join the tables using the relation

$q = Doctrine_Query::create()
     ->select('e.*, i.itemName, i.itemtypeId')
     ->from('Model_EventItem e')
     ->leftJoin('Model_EventItem.Model_Item i')
     ->where('e.eventitemId = ?', $event->eventId)
     ->orderBy('i.itemName ASC');

这篇关于学说加入DQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆