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();
}
2
Answers
You are using a Codeigniter 3 function
result_array
so try the following:I am using the following to return all data rows for Users Table:
Make sure you are using the right Model at the top of controller above the class name:
here is the function:
This is the Model: