sea_1987
sea_1987

Reputation: 2954

symfony + doctrine help

I am looking for some, I have the following table setup in my test symfony site,

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

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

From this I hope you can see that there is a relationship between event and event_signup.

I want to know how I can get the names for the people that have signed to an event, with mysql I would do something similar too,

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

How could I write in the styl of Doctrine?

Upvotes: 0

Views: 130

Answers (2)

PurplePilot
PurplePilot

Reputation: 6612

Go here

It looks like this

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

Upvotes: 1

Dan Grossman
Dan Grossman

Reputation: 52372

If you have defined the relationships correctly in your schema file, you would be able to first retrieve the event object you want, then just write $event->getEventSignups() to get the related objects, and call ->getName() on them to get the names.

Upvotes: 1

Related Questions