我有一个用户模型和一个 user_profile 模型,我正在尝试使用以下函数获取特定用户和相关的 user_profile。如果我注释掉 include_related 行,它可以工作并根据 user_id 获取用户,但如果我尝试使用 include_related 来拉入用户配置文件字段,它只会返回数据库中的第一个用户,而不是基于 user_id 的用户。这里出了什么问题?
function edit_admin_user(){
//check user is logged in and has admin rights
$this->login_manager->check_login(1);
//get user id from the uri segment
$user_id = $this->uri->segment(3);
$user = new User();
$user->get_by_id($user_id);
//$user->include_related('user_profile', array('firstname','surname', 'telephone', 'address1', 'address2', 'city', 'postcode'), TRUE, TRUE)->get();
//set the content for the view partial (this is the actual content of the page)
$content_data['user'] = $user;
$data['content'] = $this->load->view('admin/edit_admin_user', $content_data, TRUE);
$data['page_title'] = 'Get Stuffed | Admin Area | Edit Admin User';
$this->load->view('admin/index', $data);
}