为codeigniter中的where子句传递不同类型的变量

时间:2018-08-06 07:47:20

标签: php codeigniter

我需要打印$data2['hasil2']结果,但是结果只打印空数组Array ( )。谁能告诉我在tampilSos函数中传递$data1$semester的正确方法吗?

public function insertOrtu(){
    $Semester= $_POST['Semester'];
    $person=$this->session->userdata('idperson');
    $data1=$this->M_Ortu->tampilIdsiswa($person);
    $data2['hasil2']=$this->M_Ortu->tampilSos($data1, $Semester);
    print_r($data2['hasil2']);
}

这里是我的模型

public function tampilIdsiswa($person){
        $this->db->select('idsiswa');
        $this->db->from('siswa a');
        $this->db->join('siswa_kelas b','a.induk=b.induk','left');
        $this->db->where('idperson',$person);
        $data=$this->db->get();
        return $data->row()->idsiswa;
    }

    public function tampilSos($idsiswa, $semester){
        $array = array('idsiswa' => $idsiswa, 'kdSemester' => $semester, 'kdmapel'=>'sos');
        $this->db->select('*');
        $this->db->from('nilai_siswa a');
        $this->db->join('master_nilai b','a.idnilai=b.idnilai','right');
        $this->db->where($array);
        $data = $this->db->get();
        return $data->result();
    }

0 个答案:

没有答案