CodeIgniter Forums
Message: Call to a member function row() on boolean - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Message: Call to a member function row() on boolean (/showthread.php?tid=78038)



Message: Call to a member function row() on boolean - gelson - 11-23-2020

Hey guys, took me the entire week to get familiarise with your CI FrameWork. However been having an issue with fetching and inserting data into the sqli database... I checked the Database connectivity config file and it seems fine.

anyways this is my issue below:
----------------------------------------------------------------------------------------
An uncaught Exception was encountered
Type: Error

Message: Call to a member function row() on boolean

Filename: /application/models/Login_model.php

--------------------------------------------------------------------------------------
and this is my code:

<?php

class login_model extends CI_Model
{
function cek_login($where)
{

$this->db->order_by('user_name', 'DESC');
print_r($this->db->get_where('admin', $where)->row());
$query=$this->db->get_where('admin', $where)->row_array();

$data = array();
if($query !== FALSE && $query->num_rows() > 0){
foreach ($query->result_array() as $row) {
$data[] = $row->row_array();
}
}

return $data;

}
}
----------------------------------------------------------------------------------------------------
anywayz hope someone out there with enough experience is able to really help me solve this.


RE: Message: Call to a member function row() on boolean - sammyskills - 11-23-2020

Just for clarity,

1. Your class name should be the same with the file name.
Code:
class Login_model
and not login_model

2. Why are you "printing" the row()
Code:
row()
?


RE: Message: Call to a member function row() on boolean - includebeer - 11-25-2020

(11-23-2020, 05:15 AM)gelson Wrote: Hey guys, took me the entire week to get familiarise with your CI FrameWork. 

...and you decided to learn CI 3 instead of CI 4?

Anyway, maybe look at this tutorial in the user guide: http://codeigniter.com/userguide3/tutorial/news_section.html

PHP Code:
$query $this->db->get_where('news', array('slug' => $slug));
return 
$query->row_array();