Can findAll() return the same model more than once?


I have a MANY_MANY relationship of Employees and Projects. I want to generate a table listing Employees by project. If an Employee is on more than one project, he would be listed more than once in the table. The columns of the table are all Employee information (no Project details), so it’s an Employee table, but it’s organized by Project.

Is there a way to do a findAll() of Employees that results in multiple instances of the same Employee in the list. Just like you’d see in the SQL output of a mm relationship being joined?



I found a solution that seems to work.

I created a view EmployeeJoinProject that includes everything in Employee and also the project ID and name. The ActiveRecord for this view I created by extending the Employee AR. I overrode a few functions, for example the primary key of this view is array(‘id’,‘projectId’). It all seems to work, though it seems like a hack.

If anyone has any other ideas, let me know.