php - CODEIGNITER call to a member function num rows on boolean -


please have issue codeigniter. when try log here result:

fatal error: call member function num_rows() on boolean in d:\xampp\htdocs\procurementsys\application\models\login_model.php on line 19

below tho code of relative file:

  <?php     class login_model extends ci_model {  //this function checks whether username , password in database or not public function check_login($username, $password){      $this->db->select('username, password, status');     $array = array('username' => $username, 'password' => sha1($password),'status' => 'active');     $this->db->where($array);     $query = $this->db->get('user');      if($query->num_rows() == 1) // if affected number of rows 1     {         return true;     }     else     {         return false;     } }  //this function returns status of user used in authentication public function user_login_data($username, $password){      $this->db->select('status');     $array = array('username' => $username, 'password' => sha1($password));     $this->db->where($array);     $query = $this->db->get('user');      if($query->num_rows() == 1) // if affected number of rows 1     {          $row = $query->row();          return $row->status;     }   //        else   //        {   //            return false;   //        } }   public function user_role($username){ // function gets user's role database      $this->db->select('role');      $this->db->where('username', $username);      $query = $this->db->get('user');      $row = $query->row(0);       return $row->role; }  public function department($username){ // function gets user's department database      $this->db->select('department');      $this->db->where('username', $username);      $query = $this->db->get('user');      $row = $query->row(0); // returns first row array of objects stored in row variable       return $row->department; }  public function get_user_id($username){ // function gets user's department database      $this->db->select('userid');      $this->db->where('username', $username);      $query = $this->db->get('user');      $row = $query->row(0); // returns first row array of objects stored in row variable       return $row->userid ; }  public function fullname($username){      $this->db->select('firstname, secondname');      $this->db->where('username', $username);      $query = $this->db->get('user');      $row = $query->row(0);      return $row;    //            foreach($query->result() $row) // returns query array of objects   //           {   //                $data[] = $row; // equates array of objects array variable   //           }   //           //           return $data;    // } }   }   ?> 

i kept searching solution , found post (call member function num_rows() on boolean) . gave me idea no real help. thanks

something count:

$this->db->select('id'); $this->db->from('table'); $this->db->where($your_conditions); $num_results = $this->db->count_all_results(); 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -