Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
268 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 Reply

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;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...