symfony + doctrine帮助

时间:2011-01-26 11:25:15

标签: php mysql symfony1 doctrine

我正在寻找一些,我在我的测试symfony网站上设置了以下表格,

event  
----------  
id
title
description
date

event_signup  
--------------
id
name
event_id

从此我希望你能看到event和event_signup之间存在关系。

我想知道如何获取已经签名参加活动的人的名字,使用mysql我也会做类似的事情,

SELECT('*') FROM event LEFT JOIN 'event_signup' ON event.id = event_signup.event_id

我怎么能写出Doctrine的风格?

2 个答案:

答案 0 :(得分:1)

如果您已在模式文件中正确定义了关系,则可以首先检索所需的事件对象,然后只需编写$event->getEventSignups()以获取相关对象,然后调用->getName()他们得到了名字。

答案 1 :(得分:1)

转到here

看起来像这样

JobeetAffiliate:
  actAs: { Timestampable: ~ }
  columns:
  url:       { type: string(255), notnull: true }
  email:     { type: string(255), notnull: true, unique: true }
  token:     { type: string(255), notnull: true }
  is_active: { type: boolean, notnull: true, default: 0 }
   relations:
   JobeetCategories:
    class: JobeetCategory
    refClass: JobeetCategoryAffiliate
    local: affiliate_id
    foreign: category_id
    foreignAlias: JobeetAffiliates