Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

php - codeigniter error with selecting data from table

I cant figure out whats wrong with my model, it said a Fatal Error occured.

Here's my model file:

function getName($no_ktp){
    $this->db->select('nama')->from('dt_prbd')->where('no_ktp', $no_ktp);
    $qry_getName = $this->db->get();

    if ($qry_getName->num_rows() > 0) {
        foreach ($qry_getName->result() as $data_getName){
            $hasil_qry_getName[] = $data_getName;
        }
        return $hasil_qry_getName;
    }
}

I got this error.

Fatal error: Call to a member function num_rows() on boolean in C:xampp[APP_PATH]M_hrd_apps.php on line 25

I thought the error is in the query, so I changed it into this:

$qry_getName = 
$this->db->select('nama')
->from('dt_prbd')
->where('no_ktp', $no_ktp)
->get();

but the error is the same,

Call to a member function num_rows() on boolean

Can anyone help me please?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Tr this

function getName($no_ktp){
     $this->db->select('nama')->from('dt_prbd')->where('no_ktp', $no_ktp);
      $qry_getName = $this->db->get();
       $result = $qry_getName->result();
       return $result;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...