I am working on codeigniter4, Right now i am trying to get all records from database but unable to find record ( getting message "We seem to have hit a snag. Please try again later...) Here is my controller file code,Where i am wrong ?
public function getusers1(){
$userModel = new UserModel();
$data['result'] = $userModel->getusers_data();
echo "<pre>";print_R($data['result']);
}
Here is my model file code
public function getusers_data()
{
$query = "SELECT * FROM registration";
$query2=$this->db->query($query);
return $data=$query2->result_array();
}
You are using a Codeigniter 3 function result_array
so try the following:
public function getusers_data(){
return $this->db->table('registration')->get()->getResultArray();
}