1

ユーザー モデルと 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);
}
4

1 に答える 1

0

メンタルブロックを抱えていた:

 $user = new User();
    $user->where('id', $user_id);
    $user->include_related('user_profile', array('firstname','surname', 'telephone',   'address1', 'address2', 'city', 'postcode'), TRUE, TRUE)->get();
于 2012-03-21T14:00:20.993 に答える