Welcome Guest, Not a member yet? Register   Sign In
Getting ID the easy way?
#1

[eluser]solid9[/eluser]
Hi guys

I created a table named 'swap'

It has fields namely,
swap_id,
seeking,
and offering.

I have this codes below that will insert the data into "swap" table.
Code:
$data = array(
   'offering' => $offer,
   'seeking' => $seek
);
$this->db->insert('swap', $data);

Lets assume the data is inserted properly.
Now how do I fetch the swap_id from "swap" table,
after inserting the data?

I can use select and use $offer as the condition for WHERE.
But I think there is a easier and better way to get the "swap_id"?

Thanks in advanced.




#2

[eluser]Krystian[/eluser]
Code:
$this->db->insert_id()
#3

[eluser]solid9[/eluser]
Thanks, I will try that.




Theme © iAndrew 2016 - Forum software by © MyBB