How to get related fields in another model from current model, using datamapper in CI?
I am a newbie user to CodeIgniter and DataMapper. I have a User model and User Group model. Both of this model has an one-to-many relationships. Is there any way I could get user_group_name in User Gro开发者_如何学Pythonup using the User model?
Start by reading the Datamapper user guide, on http://datamapper.exitecms.org.
You can include columns from a related model into the result by using include_related().
You should familiarize yourself with codeigniter first.
As for your question, I think it would be better for you to get help from the datamapper forums or the codeigniter forums.
Wanwizard and Thorpe, Thanx for both of you. I have got the solution. I only call Group model from User model. The following code would explain it.
<?php
foreach($users->all as $user)
{
$user->group->get();
}
?>
精彩评论