0

こんにちは、すべて次のコードを使用しています

function update_profile_post()  {
    $serviceName = 'update_profile';
    //getting posted values
    $ip['user_id'] = trim($this->input->post('user_id'));
    $ip['firstname'] = trim($this->input->post('firstname'));
    $ip['lastname'] = trim($this->input->post('lastname'));
    $ip['city'] = trim($this->input->post('city'));
    $ip['state'] = trim($this->input->post('state'));
    $ip['address'] = trim($this->input->post('address'));
    $ip['phone_number'] = trim($this->input->post('phone_number'));
    $ip['is_pic_changed'] = trim($this->input->post('is_pic_changed'));

    $ipJson = json_encode($ip);
    //validation
    $ip_array[] = array("user_id", $ip['user_id'], "not_null", "user_id", "User ID is empty."); 
    $ip_array[] = array("firstname", $ip['firstname'], "not_null", "Firstname", "Firstname is empty."); 
    $ip_array[] = array("lastname", $ip['lastname'], "not_null", "lastname", "Lastname is empty.");
    $ip_array[] = array("city", $ip['city'], "not_null", "city", "City is empty.");
    $ip_array[] = array("state", $ip['state'], "not_null", "state", "State is empty.");
    $validation_array = $this->validator->validate($ip_array);
    print_r ($validation_array);
    if ($validation_array !=1) {
        $data['message'] = $validation_array;
        $retVals = $this->clamo_lib->return_status('error', $serviceName, $data, $ipJson);
    } 
    if ($ip['is_pic_changed'] == '1') {
        $this->load->library('uploader');
        $uploadPhoto = $this->uploader->upload_image($_FILES['profile_pic'], $ip);
        if ($uploadPhoto == 'failed') {
            $data['message'] = 'Upload failed. Please try again';
            $retVals = $this->clamo_lib->return_status('error', $serviceName, $data, $ipJson);
        } else {
            $retVals = $this->user_model->user_update_profile_pic($ip, $uploadPhoto,$serviceName);
        }
    } 
    else{
        $retVals = $this->user_model->user_update_profile($ip, $serviceName);
    }

    header("content-type: application/json");
    echo $retVals;
    exit;
}

モデル

function user_update_profile($input, $serviceName){
        $ipJson = json_encode($input);
        $updateArray = array(
            'user_id' => $input['user_id'],
            'firstname' => $input['firstname'],
            'lastname' => $input['lastname'],
            'address' => $input['address'],
            'city' => $input['city'],
            'state' => $input['state'],
            'phone_number' => $input['phone_number'],
            'user_modified_date' => date('Y-m-d H:i:s'),
        );
        $this->db->where('user_id', $input['user_id']);
        $update = $this->db->update('users', $updateArray);
        if ($update) {
            $data['message'] = 'User profile updated Successfully.';
            $status = $this->clamo_lib->return_status('success', $serviceName, $data, $ipJson);
        } else {
            $data['message'] = 'Error In Updating user profile';
            $status = $this->clamo_lib->return_status('error', $serviceName, $data, $ipJson);
        }
        return $status;
    }

ここでの問題は、正常に更新されたメッセージを直接提供していることですが、db でチェックしているときに、すべての値が null になっているため、何が間違っていたのかが原因です。ありがとう

4

0 に答える 0