我有显示json数据,但没有正确显示我想要输出,请建议我。
{
"Childs": "12,16",
"childs_id": "12",
"firstname": "Ratanveer",
"lastname": "Singh",
"admission_no": "CS-101",
"roll_no": "1121510025",
"admission_date": "2018-07-11",
"rte": "No",
}
我让api显示此数据仅是孩子“ 12”,但我想同时以json格式显示孩子“ 16”和“ 12”的数据
模式: 这是我的模特
public function getProfile()
{
/* ---------- Join Query ---------------- */
$childs = $this->input->get_request_header('Childs-ID', TRUE);
//this is my query
$this->db->select('users.childs AS Childs,users_authentication.childs_id,students.firstname,students.lastname,students.admission_no,students.roll_no,students.admission_date,students.firstname,students.lastname,students.rte,students.mobileno,students.email,students.state,students.city,students.pincode,students.religion,students.cast,students.dob,students.gender,students.current_address,students.permanent_address,students.bank_account_no,students.bank_name,students.ifsc_code,students.father_name,students.father_phone,students.father_occupation,students.mother_name,students.mother_phone,students.mother_occupation,students.guardian_name,students.guardian_relation,students.guardian_phone,students.guardian_occupation,students.guardian_address,students.guardian_email');
$this->db->from('users');
$this->db->join('students', 'students.id = users.childs','INNER');
$this->db->join('users_authentication', 'users_authentication.childs_id = students.id','INNER');
$this->db->where('user_id',$childs);
$this->db->GROUP_BY('user_id');
$query = $this->db->get()->result();
return ($query);
}
控制器: 这是我的控制器
public function childProfileDetails()
{
$method = $_SERVER['REQUEST_METHOD'];
if($method != 'GET')
{
json_output(400,array('status' => 400,'message' => 'Bad request.'));
}
else
{
$this->load->model('MyModel');
$response = $this->MyModel->auth();
if($response['status'] == 200)
{
$resp = $this->MyModel->getProfile();
json_output($response['status'],$resp);
}
}
}