Trying to get property of non-object di codeigniter

Tolong bantuannya temen", bener" mentok ini hmm Pesan : Message: Trying to get property of non-object

Filename: controllers/web.php

Line Number: 641

Controller

 $data['web'] = $this->m_web->getDatasaldo($this->session->userdata("id_user"))->result();
        $saldo = $this->m_web->cariSaldoCustomer($this->session->userdata('id_user'));
        $data['saldo'] = $saldo->saldo; // line 641
        $this->template->display('web/topup', $data);

Model

     function cariSaldoCustomer($nama)
    {
        $this->db->distinct();
        $this->db->select("*");
        $this->db->from("kartu");
        $this->db->join("user","user.id_user=kartu.id_user");
        $this->db->where("user.id_user",$nama);
        return $this->db->get()->row();
    }
     function getDatasaldo($id){

        $query=$this->db->query("select * from saldo_topup where id_user = '$id' order by tgl_topup desc");
        return $query;

    }
avatar deni2
@deni2

58 Kontribusi 11 Poin

Diperbarui 6 tahun yang lalu

1 Jawaban:

coba ubah function ini:



function cariSaldoCustomer($nama)
    {
        $this->db->distinct();
        $this->db->select("*");
        $this->db->from("kartu");
        $this->db->join("user","user.id_user=kartu.id_user");
        $this->db->where("user.id_user",$nama);
        //return $this->db->get()->row(); //ubah ini
        return $this->db->get()->result_array(); // jadi ini
    }
avatar keccikun
@keccikun

368 Kontribusi 197 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban