I'm using Propel ORM v2 to retrieve records from a table which is linked to records of another table using foreign key. I'd like to return only certain fields from both the parent table and the child table.
What is the best way to do this?
My table structure looks like this:
Table: User
- Id
- Name
- Age
- MaritalStatus
Table: Profile
- UserId (FK->User.Id)
- Street
- City
- State
- Country
- TelephoneNumber
I have tried the following but the query does not return the desired User
object with children Profile
objects and only the selected fields of Id, Name
for the User
object and TelephoneNumber
for the Profile
child objects:
\UserQuery()::create
->select(array('Id', 'Name', 'Profile.Telephonenumber'))
->leftJoinWithProfile()
->find()
->toArray();
Any advise is greatly appreciated