Codeigniter select query not working fine

code:

   $this->db->select("reserve_number");
        $this->db->from($this->table_name);
        $this->db->order_by("reserve_id", "desc");
        $this->db->limit(1);
        $query = $this->db->get();
        $result = $query->result();
        return $result;

output:

Array ( [0] => stdClass Object ( [reserve_number] => L290517122756-5678 ) )

how can i retrive this data anyone explain me.

i got the output like L290517122756-5678

 $this->db->select("reserve_number");
        $this->db->from($this->table_name);
        $this->db->order_by("reserve_id", "desc");
        $this->db->limit(1);
        $query = $this->db->get();
        $result = $query->result_array();
        return $result;

Calling $query->result() returns each result as a generic object (stdClass), which means you can access the properties (i.e. columns) with the arrow notation, as you would a normal PHP object:

$result = $query->result();

// $result is an array of results, so loop over it
foreach($result as $row) {
  echo $row->reserve_number;
  // L290517122756-5678
}
1 Like

Have you tried the documentation? There are some very good examples of query results.

https://www.codeigniter.com/user_guide/database/results.html

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.