Works just fine... Thanx :)

On Sep 4, 4:42 pm, luigi7up <[EMAIL PROTECTED]> wrote:
> Thanx... I'll give it a try
>
> On Sep 4, 4:23 pm, teknoid <[EMAIL PROTECTED]> wrote:
>
> > Your usage of find() is incorrect in the example: find('count'), ...
> > should be find('count', ...
>
> > That being said, to access associated model from a controller you
> > would use:
> > $this->Motive->Point->find('count',
> > array('conditions'=>array('Point.user_id'=>$userId, 'Point.motive_id'=>
> > $motiveId... etc..
>
> > On Sep 4, 9:31 am, luigi7up <[EMAIL PROTECTED]> wrote:
>
> > > Hello Im having problem with performing find function in following
> > > scenario:
>
> > > I have a voting sistem for motives in gallery. User can vote only once
> > > for one motive. So in table Points there is an entry with
> > > corresponding user_id and motive_id when user votes.
>
> > > I have three models: USER, Motive, Points
>
> > > User $hasMany motives
> > > Motive $belongsTo user
>
> > > Motive $belongsTo User
> > > Motive $hasMany motivePoints
>
> > > Points $belongsTo Motive
> > > Points $belongsTo User
>
> > > When user wants to vote i have to perform following SQL query to check
> > > if he already voted :
>
> > > Select * from motives _points WHERE user_id='$id' AND motive_id =
> > > '$motive_id'
>
> > > I want to perform find('count') with this conditions in
> > > Motives_controller. If it returns >0 , user already voted for this
> > > motive. I tried this:
>
> > > $this->Motive-
>
> > > >find('count'),array('conditions'=>array('Point.user_id'=>26))
>
> > > It should return 1 because there is only one entry for user 2 in table
> > > Points but it returns 3
>
> > > If I look in debug($this->Motive-
>
> > > >find('all'),array('conditions'=>array('Point.user_id'=>26))) i get:
>
> > > ***************************************************
> > > ***************************************************
>
> > > Array
> > > (
> > >     [0] => Array
> > >         (
> > >             [Motive] => Array
> > >                 (
> > >                     [id] => 1
> > >                     [user_id] => 26
> > >                     [title] => Nije Vuk Ovca
> > >                     [folder] => motives/motiv_1
> > >                     [points] => 45
> > >                     [created] => 2008-09-01 11:44:45
> > >                     [modified] => 2008-09-01 15:07:48
> > >                 )
>
> > >             [User] => Array
> > >                 (
> > >                     [id] => 26
> > >                     [username] => luigi7up
> > >                     [password] => 670a2a8ff7b5df64e8205775d4666b55
> > >                     [email] => [EMAIL PROTECTED]
> > >                     [first_name] => Luka
> > >                     [last_name] => Eterovic
> > >                     [group_id] => 2
> > >                 )
>
> > >             [Point] => Array
> > >                 (
> > >                 )
>
> > >         )
>
> > >     [1] => Array
> > >         (
> > >             [Motive] => Array
> > >                 (
> > >                     [id] => 2
> > >                     [user_id] => 27
> > >                     [title] => Killabear
> > >                     [folder] => motives/motiv_2
> > >                     [points] => 130
> > >                     [created] => 2008-09-01 11:46:08
> > >                     [modified] => 2008-09-03 17:16:31
> > >                 )
>
> > >             [User] => Array
> > >                 (
> > >                     [id] => 27
> > >                     [username] => gazda
> > >                     [password] => 7be96ec0264ec22ea292b1484ec88da3
> > >                     [email] => [EMAIL PROTECTED]
> > >                     [first_name] => Administratrija
> > >                     [last_name] => Admic
> > >                     [group_id] => 3
> > >                 )
>
> > >             [Point] => Array
> > >                 (
> > >                     [0] => Array
> > >                         (
> > >                             [id] => 1
> > >                             [user_id] => 26
> > >                             [motive_id] => 2
> > >                             [points] => 5
> > >                             [created] => 0000-00-00 00:00:00
> > >                             [modified] => 0000-00-00 00:00:00
> > >                         )
>
> > >                 )
>
> > >         )
>
> > >     [2] => Array
> > >         (
> > >             [Motive] => Array
> > >                 (
> > >                     [id] => 3
> > >                     [user_id] => 31
> > >                     [title] => Funny Geraffe
> > >                     [folder] => motives/motiv_3/
> > >                     [points] => 38
> > >                     [created] => 2008-09-01 15:20:23
> > >                     [modified] => 2008-09-04 10:57:43
> > >                 )
>
> > >             [User] => Array
> > >                 (
> > >                     [id] => 31
> > >                     [username] => marljivi
> > >                     [password] => eb01e22ae152e997783f9617c4dd535f
> > >                     [email] => [EMAIL PROTECTED]
> > >                     [first_name] => Marljivi
> > >                     [last_name] => Marljivi
> > >                     [group_id] => 3
> > >                 )
>
> > >             [Point] => Array
> > >                 (
> > >                 )
>
> > >         )
>
> > > )
>
> > > ***************************************************
> > > ***************************************************
>
> > > I was playing with recursive = 2 and behaviour Containable to get this
> > > work but I need help.
>
> > > Summary:
> > > I need check in Motives_Controller if table Points, that is
> > > assocciated to motives table, contains user_id & motive_id values and
> > > return true/false or number of records...
>
> > > Thanks
>
>
--~--~---------~--~----~------------~-------~--~----~
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