Hello,
in my database, there is a HABTM association between model "rooms" and
"staffs".
In my index-view of "staffs", when i retrieve the data, i'd like to
have an extra column for each datarow with all rooms, which belongs to
the current staff(id).
The join table contains "room_id" and "staff_id" and is called
"rooms_staffs".
**table staff: controller:**
{{{
function index()
{
$this->set('staffs', $this->paginate('Staff'));
}
}}}
**table staff: part of the view:**
{{{
<?php foreach ($staffs as $staff): ?>
<tr>
<td><?php echo $staff['Staff']['id']; ?></td>
<td><?php echo $staff['Staff']['forename']; ?></td>
<td><?php echo $staff['Staff']['surname']; ?></td>
<td><?php echo $staff['Staff']['telephon_number']; ?></td>
<td><?php echo $staff['Staff']['e_mail']; ?></td>
<td>at this place, i need all description fields from the
matching rooms</td>
</tr>
<?php endforeach; ?>
}}}
debug($staffs) result in index-view of staff:
{{{
Array
(
[0] => Array
(
[Staff] => Array
(
[id] => 3
[forename] => Patrick
[surname] => Hartung
[telephon_number] => 0124144214
[e_mail] => [email protected]
[full_name] => 3 (Hartung)
)
[Room] => Array
(
[0] => Array
(
[id] => 1
[location_id] => 1
[description] => Serverraum
)
[1] => Array
(
[id] => 3
[location_id] => 2
[description] => Buero
)
)
)
}}}
When i try: echo $staff['Room']['0']['description']; i can get
the first datarow. but how can i get all in my new column?
I've read in the book but i really don't know how to code this :(
Thanks a lot if someone can help!
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 [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