Btw when I add debug($queryData); it confirms the contain array is
present:

app\models\ticket.php (line 175)

Array
(
    [conditions] => Array
        (
            [Ticket.ticket_status] => New
        )

    [fields] => Array
        (
            [0] => Ticket.ticket_id
        )

    [joins] => Array
        (
        )

    [limit] => 51
    [offset] =>
    [order] => Array
        (
            [0] =>
        )

    [page] => 1
    [group] =>
    [callbacks] => 1
    [contain] => Array
        (
            [ClientUser] => Array
                (
                    [fields] => Array
                        (
                            [0] => ClientUser.user_group_id
                        )

                )

        )

)

But it is not taking effect in the sql:

Warning (512): SQL Error: 1054: Unknown column
'ClientUser.user_group_id' in 'where clause' [CORE\cake\libs\model
\datasources\dbo_source.php, line 525]

Query: SELECT `Ticket`.`ticket_id` FROM `tickets` AS `Ticket` WHERE
`Ticket`.`ticket_status` = 'New' AND
`Ticket`.`ticket_support_group_id` = 2 AND `Ticket`.`ticket_status` !=
'Deleted' AND ((`Ticket`.`ticket_client_group_id` = 84) AND
(`ClientUser`.`user_group_id` = 204) AND (((`Ticket`.`ticket_openedby`
= 1024) OR (`Ticket`.`ticket_client_user_id` = 1024)))) LIMIT 51

On 21 Aug, 09:24, Adrian <[email protected]> wrote:
> Hi
>
> I am trying to set my contain array from within the models beforeFind
> () callback so a certain model is always contained. I have the
> following code:
>
>         function beforeFind($queryData) {
>                 // Always contain the client user
>                 if(empty($queryData['contain']['ClientUser'])) {
>                         $queryData['contain']['ClientUser']['fields'] = array
> ('ClientUser.user_group_id');
>                 }
>                 return $queryData;
>         }
>
> should this not work?
>
> At the moment the find operations just ignore this.
>
> Any ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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