我新與cakephp ..對不起,如果我的問題似乎基本.. 我有模型:用戶,發佈,評論,所有相關並且需要在帖子視圖中顯示 評論....但還想顯示用戶名,我無法訪問該用戶模型的該字段。 我在post.php模型中的comment.php模型和user_id中有user_id和post_id,但是在循環內部,我如何訪問用戶模型的用戶名字段?從正在從其他表中恢復其他數據的循環中檢索數據
我有這樣的...職位/ view.ctp
<?php foreach ($post['Comment'] as $comment): ?>
<tr<?php echo $class;?>>
// this does not work
// echo $comment['user_id']['username'];
<td><?php echo $comment['user_id']; ?>
</td>
</tr>
<tr>
<td><?php echo $comment['created'];?></td>
<td></td>
</tr>
<tr>
<td><?php echo $comment['content'];?></td>
</tr>
<?php endforeach; ?>
</table>
那麼我怎麼能解決這個問題?謝謝...