I have three tables:
Project:
...
relations:
User:
local: authorId
foreign: id
Users:
class: User
local: projectId
foreign: userId
refClass: UserProjects
User:
...
relations:
Projects:
class: Project
local: userId
foreign: projectId
refClass: UserProjects
UserProjects:
columns:
id:
type: integer
primary: true
autoincrement: true
userId: integer
projectId: integer
What I would like to do is write a DQL statement to return the projects that a user is associated to. I'm trying to emulate the following:
SELECT p.*
FROM user_projects AS up
LEFT JOIN project AS p ON up.projectid = p.id
LEFT JOIN user AS u ON up.userid = u.id
WHERE u.id = 1
Reading through the Doctrine instructions I came up with the following (u.* is in there because it complained about u not being used in the select statement):
$q = Doctrine_Query::create()
->from('Model_User u')
->select('u.*, p.*')
->leftJoin('u.Projects p');
$result = $q->execute();
What it returns though is a data set containing a single Model_User object with a 'Projects' property filled in with the associated projects. I'd like to just have the projects returned if possible, but I can't seem to figure that out. Is it possible?