0

Hy, i have problem with my code. i use RESTful web service with CI Framework.

//model in Rest Server
public function ambil($semester, $matkul, $kelas){
    $this->db->select('mahasiswa.nama, mahasiswa.nim, k.grup');
    $this->db->from('mhs mahasiswa');
    $this->db->join('krs k', 'k.nim=mahasiswa.nim');
    $this->db->where(array('k.kmk'=>$matkul, 'k.grup'=>$kelas));
    $query = $this->db->get();

    return $query->result_array(); 
}

//controller in Rest Server
public function ambil_get(){
    $this->load->model('M_data');
    if(!$this->get('semester')){
        if (!$this->get('matkul')) {
            if (!$this->get('kelas')) {
                $this->response(NULL, 400);
            }
        }
    }

    $data = $this->M_data->ambil($this->get('semester','matkul','kelas'));
    if($data)
    {
        $this->response($data,200);
    }
    else
    {
        $this->response(NULL, 404);
    }
}

//Controller in Client Server
public function getData(){
    $semester = $this->input->post('vsemester');
    $matkul = $this->input->post('vmatkul');
    $kelas = $this->input->post('vkelas');

    $data = $this->rest->get('ambil/semester/'.$semester.'/matkul/'.$matkul.'/kelas/'.$kelas.'', 'json');
    var_dump($data);
    foreach ($data as $key => $value) {
            echo '<tr>';
            echo '<td>'.($key+1).'</td>';
            echo '<td>'.$value->nim.'</td>';
            echo '<td>'.$value->nama.'</td>';
            echo '<td>'.$value->grup.'</td>';
            echo '</tr>';
        }
}

I'm using this code to call function ambil_get in controller of rest server but it doesn't work. Anybody knows why it doesn't work? And how to fix it? Thank you so much :)

zakhefron
  • 1,403
  • 1
  • 9
  • 13

0 Answers0