Hi AD7six,
Thank you for the tip on using pr instead of echo. I had a pretty
good idea of what it was doing (I have to deal with a lot of arrays
and hashmaps at work), but I am still not entirely sure of how to fix
it. I changed my tournament function to look like this:
function tournament($id)
{
$this->checkSession();
$this->pageTitle = 'Tournament';
$this->Poker->id = $id;
$this->set('poker',$this->Poker->read());
}
Because I saw it in the blog example but I still received the same
results:
1
Brandon
Skeen
[EMAIL PROTECTED]
password
fallenrayne
2007-10-18
2007-10-18
1
Array ( [id] => 1 [fname] => Brandon [lname] => Skeen [email] =>
[EMAIL PROTECTED] [password] => password [username] => fallenrayne
[created] => 2007-10-18 [modified] => 2007-10-18 [type] => 1 )
Array ( [id] => 2 [fname] => Carrie [lname] => Skeen [email] =>
[EMAIL PROTECTED] [password] => password [username] => cskeen [created]
=> 2007-10-18 [modified] => 2007-10-18 [type] => 1 )
So the first array is being displayed, one element at a time, and then
it goes on and gets the two sets of data that I am expecting.
BTW, sorry for the long delay on posting. I can't access any of this
stuff while at work so I had to wait to get home and try some of this
out. I really appreciate the help though.
On Nov 2, 6:07 am, AD7six <[EMAIL PROTECTED]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---