0
我想在不創建表的連接的情況下選擇一列(具有外鍵約束)。我有兩個表名爲eventupdate
和eventcategory
。 event
列在兩個表中都很常見。每當我嘗試下面的代碼,它會給出錯誤。在沒有連接兩個表的情況下選擇一列(具有外鍵)
請給點建議。我不想創建一個連接。
$qb2 = $this->em->createQueryBuilder();
$from = 'Entities\EventCategory cat';
$qb2->add('from',$from)
->select('cat.event')
->Where('cat.id=3);
$query=$qb2->getQuery();
*「它給出錯誤...」*錯誤是什麼?爲什麼你用[低級API](http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/query-builder.html#low-level-api) > add'而不是普通的' - > from'方法... – Wilt