On Nov 2, 3:11 am, fallenrayne <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> This is my first post here and it is a weird problem that I have been
> trying to fix for a few days now with no luck.  I have a HABTM that is
> connecting a poker tournament table with a users table so that I can
> track which users were at the poker tournament.  When I run the HABTM
> I end up getting the first user's data, each field, in a separate
> element in the array, then I get the users in the array the proper
> way.  Here is my code:
>
> var $hasAndBelongsToMany = array('User' =>
>     array('className'    => 'User',
>         'joinTable'    => 'users_poker',
>         'foreignKey'   => '',
>         'associationForeignKey'=> '',
>         'conditions'   => '',
>         'order'        => '',
>         'limit'        => '',
>         'unique'       => true,
>         'finderQuery'  => '',
>         'deleteQuery'  => '')
>     );
>
> It is a very basic HABTM so I left most things default.  In the
> tournament method for my poker controller I have:
>
>         function tournament($id)
>         {
>                 $this->checkSession();
>                 $this->pageTitle = 'Tournament';
>                 $this->set('poker',$this->Poker->findById($id));
>         }
>
> Then in the tournament view I have:
>
> <h1>Tournament</h1>
> <hr />
> <?php
> foreach($poker['User'] as $user):
>         echo $user['username'];
>         echo "<br/>";
> endforeach;
> ?>
>
> When it prints out I end up getting something that looks like:
>
> 1
> B
> S
> d
> f
> 2
> 1
> 1
> 7
> fallenrayne
> carrie
>
> Of course only the last 2 rows are actually correct, the rest of the
> rows are the first character of each field in the row for my username.

Try using pr instead of echo and you'll see that the data isn't in the
form you are expecting. Hint: Find*All*By

hth,

AD


--~--~---------~--~----~------------~-------~--~----~
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