Sorry to beat what is certainly a very uncomfortable horse...

The db is as follows
Users HABTM Groups HABTM Reports  (using Group_Users and Group_Reports
tables to manage relationships)

I want to have conditions on both users and reports while returning a
particular report only once. Basically I'm using groups for access
control. Session gives user id, which is a member of one or more
groups, each giving access to one or more reports. The problem is that
just about any query I build using 'the framework' gives me multiple
copies of the report (because a report can be in more than one group
and a user could be in more than one of those groups.). I can do this
with a SQL query, but then I lose all that paginate magic and
potential future magic. I could also run a array_unique on the
resultset, but that too has it's problems.

Here's an example of what I was attempting to use.

$this->paginate = array(
        'fields'                => 'id',
        'conditions'    => $userConditions,
        'contain'               => array(
                'Group'                 => array(
                        'fields'        => array(),
                        'Report'        => array(
                                'conditions'    => $reportConditions,
                                'fields'                => $reportFields
                        )
                )
        )
);

Where among other things userConditions includes User.id =>
Session['User']['id']
and Reports are filtered by type

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to