Reputation: 243
To begin with, I'm aware to the:
$this->db->insert_id();
With that I will get the id of the last inserted mysql value, but I didn't manage to find any info about the way to retrieve the last inserted value to another colomn, let's say we have a field with name weight, I will get the id with insert_id() but how to get the weight value without the need to write a SQL statement?
I was reading the documentation and only thing I can maybe use is the last_query() method, but I'm not that sure if that will work, is there anything similar?
Upvotes: 1
Views: 1040
Reputation: 1680
You can also get last record by using
$id = $this->db->insert_id();
$query = $this->db->get_where('your_table_name', array('your_id_field' => $id));
return $query->row();
Upvotes: 1