Tuesday, September 28, 2010

Re: Join returns 2 arrays - how can I change that?

did u try this?....

$groups = array_merge($groups["usergroups"], $groups["user"]); // but if u have same key's aka id field is in users and usergrups table....it will be merged (replaced);


--
Tilen Majerle


2010/9/27 quas <pantyhosehd@googlemail.com>
Hi there,

I have a problem with the returning data of my database when I use
cakephp.

when I make a join with 2 tables I get as returnvalue 2 arrays. One
for each table...

for example
join: user & usergroup

results in

array[user] and array[usergroup]

I am not sure if this is the normal cakephp behaviour or if I make an
mistake
but it's a little annoying to use:

       <?php echo($groups['usergroup']['title'])?>
       <?php echo($groups['user']['username'])?>

in my view.

How can I achieve that I only get one array back with the joined data
so that I can use :

<? echo $groups['title'] ?>
<? echo $groups['username'] ?>

Thanks a Lot

Quas

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: