I have the following database structure
I have a relationship set up under my user that is a self::HAS_MANY
‘taskpermissions’=>array(self::HAS_MANY, ‘TaskPermission’, ‘user_id’)
That works great to get me the bulk of my data.
Then the client_task_permissions class TaskPermission has three relationships:
‘client’=>array(self::HAS_ONE, ‘Client’, array(‘ID’=>‘CLIENT_ID’)),
‘task’=>array(self::HAS_ONE, ‘Task’, array(‘ID’=>‘TASK_ID’)),
‘employee’=>array(self::BELONGS_TO, ‘Employee’, ‘USER_ID’),
My challenge now is figuring out how to sort my $user->taskPermissions records first by client.name and then by task.name:
I would usually use a series of joins to accomplish this with SQL and join in the client and task records with the permissions record to add the entities and sort by them. I can’t find any documentation here or via searching the forums (I’ve spent hours digging).
All I can seem to do is add an ‘order’=>’’ parameter to sort by any of the task_permissions table fields, but it won’t let me sort of the task_permission relationships.
Any good way to accomplish this? Seems like something that should be fairly common.