Reputation: 16062
Hi I'm using Codeigniter and would love a solution in CI but can suffice with mysqli or PDO.
I was wondering if there is a way to get a column of the last inserted row in MySql 5.1.54
The reason is I'm inserting a null value which then a trigger changes that null into some calculated value and instead of getting the last inserted id and querying for that value.
Is there some way this can be done?
In case I wasn't clear : I know I can run a query on last inserted id, I mean can I get last inserted "column"?
Upvotes: 0
Views: 1007
Reputation: 4446
The PDO comes with lastInsertId method. You can then SELECT * FROM table WHERE id=return_of_this_function
.
Upvotes: 0
Reputation: 708
You can get the last inserted id by
$this->db->insert_id();
and select the last row and use it normally
ref Query Helper
Upvotes: 2