Krishna thakor
Krishna thakor

Reputation: 185

select query doesn't give result in codeigniter?

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.

Upvotes: 0

Views: 89

Answers (1)

Pradeep
Pradeep

Reputation: 9717

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

Upvotes: 4

Related Questions