0

Select query don't show records array.

Below is my get_all_user method code.

public  function get_all_user(){

 $query = $this->db->query("select * from user");
 echo"<pre/>";print_r($query);die;
}

when i print $query it shows result_array() empty. Please help me to solve this problem.

1
  • 1
    use this echo"<pre/>";print_r($query->result());die;
    – Deepak
    Jul 11, 2018 at 6:06

1 Answer 1

4

Should be like this :

public function get_all_user()
{
  $query = $this->db->query("select * from user");
  $results = $query->result();
  echo"<pre/>";print_r($results);die;
}

Or You can simply do like this :

public function get_all_user()
{
  $results = $this->db->get("user")->result();
  print_r($results);die;
}

For more : https://www.codeigniter.com/user_guide/database/query_builder.html

2
  • Thanks It is really helpful. Jul 11, 2018 at 8:00
  • pleasure is mine , happy coding
    – Pradeep
    Jul 11, 2018 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.