Hi everyone I’m getting pissed off with a seemingly easy table join, but I can’t tell what is going wrong since I don’t know what the query is. Is there a way to debug Active Records? I found one here, but how do I get access to the connection object?
The real issue is I’m trying to pull up all projects that a user is associated with (relation ship is in a joiner table)
projects table -> user_projects table -> users table
Project::find('all', array(
'select' => 'user_projects.id, title, description, last_update',
'conditions' => array('user_projects.user_id = ?', $user_id),
'joins' => 'LEFT JOIN user_projects ON projects.id = user_project.project_id'
));
Well I discovered the answer to my own issue somehow, to get the last query:
Model::connection()->last_query