Welcome Guest, Not a member yet? Register   Sign In
Returning Inserted Primary ID
#1

[eluser]whobutsb[/eluser]
Hello all I'm using a MSSQL DB for my application and I was wondering if there was a simple way of returning the newly inserted key after I do my insert command.

In CI I'm using this code:
Code:
$data = array('contactID' => $contactID, 'fieldcategoryID' => $fieldcategoryID, 'field_name'=>$fieldname, 'field_value'=>$fieldvalue);
$add = $this->db->insert_string('tblContactDetails', $data);

I was wondering if there was a helper method to return the newly inserted key in the database?

Usually I would write my SQL code as follow
INSERT INTO table (fields, fields, fields)
OUTPUT Inserted.ID
VALUES (Value1, Value2, Value3)

Then using a php mssql_result get the newly inserted ID.

Thanks for the help!
Steve


Messages In This Thread
Returning Inserted Primary ID - by El Forum - 12-11-2008, 01:34 PM
Returning Inserted Primary ID - by El Forum - 12-11-2008, 01:56 PM
Returning Inserted Primary ID - by El Forum - 12-11-2008, 01:58 PM
Returning Inserted Primary ID - by El Forum - 12-11-2008, 02:09 PM
Returning Inserted Primary ID - by El Forum - 12-11-2008, 02:33 PM
Returning Inserted Primary ID - by El Forum - 12-11-2008, 02:46 PM
Returning Inserted Primary ID - by El Forum - 12-11-2008, 09:46 PM
Returning Inserted Primary ID - by El Forum - 12-11-2008, 10:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB