php - Redirect to controller if query in model return empty in Codeigniter 3

Solution:

A simple way to redirect.

$q =  $this->db->query()->row();
 If($q==""){
   redirect('url/page');
  }

Answer

Solution:

public function get_user_detail($id)
{
  $query = $this->db->where('user_id', $id)->get('user');
    $query != "" ? redirect('actual-controller ($query)') : redirect('other-controller');
}

controller($query){ return $query->row(); //your view code for view here }

Answer

Solution:

Thanks to @Vickel for pointing out. I should do the checking on the controller not in the model and don't need redirect. I was do the checking on the model and redirect.