Well, its solved.

I used the hasMany with finderQuery and limit = 9999 and its runs perfeclty.

Those are my relationship:
var $hasMany = array(
        'AtualizacoesCriadas' => array(
            'className'                => 'Atualizacao',
            'foreignKey'            => 'usuario_id'
        ),
        'AplicacoesLiberadas' => array(
            'className'                => 'Aplicacao',
            'limit'                    => '9999',
            'finderQuery'            => '
                SELECT `AplicacoesLiberadas`.* FROM `caixa_aplicacoes` AS
`AplicacoesLiberadas`
                    INNER JOIN `auth_sections` ON `auth_sections`.`path` =
"caixa"
                    INNER JOIN `auth_actions` ON `auth_actions`.`section_id`
= `auth_sections`.`id`
                        AND `AplicacoesLiberadas`.`instancia` =
`auth_actions`.`file`
                    INNER JOIN `auth_users_actions` ON
`auth_users_actions`.`action_id` = `auth_actions`.`id`
                        AND `auth_users_actions`.`user_id` = {$__cakeID__$}'
        ),
        'AtualizacoesPendentes' => array(
            'className'                => 'Atualizacao',
            'limit'                    => '9999',
            'finderQuery'            => '
                SELECT `AtualizacoesPendentes`.* FROM `caixa_atualizacoes`
AS `AtualizacoesPendentes`
                    INNER JOIN `caixa_aplicacoes` AS `AplicacoesLiberadas`
ON `AtualizacoesPendentes`.`aplicacao_id` = `AplicacoesLiberadas`.`id`
                    INNER JOIN `auth_sections` ON `auth_sections`.`path` =
"caixa"
                    INNER JOIN `auth_actions` ON `auth_actions`.`section_id`
= `auth_sections`.`id`
                        AND `AplicacoesLiberadas`.`instancia` =
`auth_actions`.`file`
                    INNER JOIN `auth_users_actions` ON
`auth_users_actions`.`action_id` = `auth_actions`.`id`
                        AND `auth_users_actions`.`user_id` = {$__cakeID__$}
                WHERE
                    `AtualizacoesPendentes`.`id` NOT IN (
                        SELECT DISTINCT(`atualizacao_id`) FROM
`caixa_usuarios_atualizacoes` WHERE `usuario_id` = {$__cakeID__$}
                    )
                GROUP BY `AtualizacoesPendentes`.`id`'
        )
    );

Cake RULES !!!

Thanks!

On Sat, Feb 23, 2008 at 10:49 AM, Renan Gonçalves <[EMAIL PROTECTED]>
wrote:

> I can use a query like this:
>
> SELECT r.* FROM revisions AS r WHERE r.id NOT IN (
>    SELECT revision_id FROM user_has_revised WHERE user_id = $__cakeId__$
> )
>
> This must work if for each user execute this query. hasAndBelongsToMany
> don't work because its fetchs a all relationship of all users on a unique
> query.
>
> I opened this ticket https://trac.cakephp.org/ticket/4204, so when I put a
> limit its will work.
>
>
> Thanks.
>
>
> On Sat, Feb 23, 2008 at 6:28 AM, francky06l <[EMAIL PROTECTED]> wrote:
>
> >
> > How did you use the $__cakeId__$ in your finder query ?
> >
> > On Feb 23, 1:43 am, "Renan Gonçalves" <[EMAIL PROTECTED]> wrote:
> > > Sorry ..
> > >
> > > I wanna do a hasAndBelongsToMany relationship. Sorry for this..
> > > I tried to use finderQuery, doing a find (one result) it's ok, but
> > with
> > > findAll don't runs...
> > >
> > > On Fri, Feb 22, 2008 at 10:21 PM, BlenderStyle <[EMAIL PROTECTED]
> > >
> > > wrote:
> > >
> > >
> > >
> > >
> > >
> > > > You might be able to do something like this in your Revision model:
> > >
> > > > function getNegativeRevisions($user_id) {
> > > >        $conditions = array('user_id' => '<> '.$user.id);
> > > >        return $this->findAll($conditions);
> > > > }
> > >
> > > > Then, in your RevisionsController:
> > > > $user_id = '5';
> > > > $negative_revisions =
> > $this->Revision->getNegativeRevisions($user_id);
> > >
> > > > I didn't test that, but it seems logical.
> > >
> > > > Matt Bowden
> > >
> > > > On Feb 22, 2:30 pm, "Renan Gonçalves" <[EMAIL PROTECTED]>
> > wrote:
> > > > > Hello!
> > >
> > > > > I have a application that has two main models (User and Revision
> > with
> > > > > relationship User has many Revision).
> > > > > I wanna to get all Revision that this User revised and all
> > Revision that
> > > > > this User don't revised. There are a way to get this information
> > using
> > > > the
> > > > > relationships?
> > >
> > > > > Thanks!
> > > > > --
> > > > > Renan Gonçalves - Software Engineer
> > > > > Cell Phone: +55 (11) 8633-6018
> > > > > MSN: [EMAIL PROTECTED]
> > > > > Web Site: renangoncalves.com
> > > > > São Paulo - SP/Brazil
> > >
> > > --
> > > Renan Gonçalves - Software Engineer
> > > Cell Phone: +55 (11) 8633-6018
> > > MSN: [EMAIL PROTECTED]
> > > Web Site: renangoncalves.com
> > > São Paulo - SP/Brazil
> > > >
> >
>
>
> --
> Renan Gonçalves - Software Engineer
> Cell Phone: +55 (11) 8633-6018
> MSN: [EMAIL PROTECTED]
>
> Web Site: renangoncalves.com
> São Paulo - SP/Brazil
>



-- 
Renan Gonçalves - Software Engineer
Cell Phone: +55 (11) 8633-6018
MSN: [EMAIL PROTECTED]
Web Site: renangoncalves.com
São Paulo - SP/Brazil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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