$post = Model_Post::find(); $post->comments; //all comments $post->comment[1]->comment_type->name; //how do I get that 'name'?
$post = Model_Post::find(1); foreach($post->comments as $comment) { //this way it works: $comment_type = Model_Comment_Types::find($comment['comment_type_id']); //fetches the fields and values of the comment_type echo $comment_type->{fieldname from comment_types table}; //this works //but I'd like to use something like this, if possible (without fetching the Model_Comment_Type manually): $comment_type = $comment->comment_type->{fieldname from comment_types table} }
foreach($post->comments as $comment) { echo $comment->comment_type->{fieldname from comment_types table}; }
It looks like you're new here. If you want to get involved, click one of these buttons!