简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM