[UPHPU] returning MySQL

David Smith DavidSmith at byu.net
Tue Feb 22 21:52:03 MST 2005


This may be the case, though no users have posted comments about it on the
manual page, which makes me think the function is safe in that regard. I
personally have never had a problem using mysql_insert_id(), even when
using mysql_pconnect(). If, however, that doesn't work for you, you can
always use the built-in function LAST_INSERT_ID() in your SQL query, as
documented here:

  http://www.mysql.com/doc/en/Getting_unique_ID.html

--Dave

<quote who="Grant Shipley">
> Someone correct me if I am wrong here but that will only return the
> last insert id for that connection.  So if you have some type of
> connection pooling or caching system in place, you might not get the
> number you are expecting.
>
> --
> Grant
>
>
> On Tue, 22 Feb 2005 16:37:53 -0700, Timothy Humphrey
> <timothy.humphrey at gmail.com> wrote:
>> How would one return the "auto increment" number from a newly created
>> record automatically?
>>
>> For example:
>> <?
>> $record = "INSERT INTO database VALUES ('', '$var_1','$var_2', '1',
>> '$var_3')";
>>                $result = $db->query($record);
>>                $db->commit();
>> ?>
>>
>> I would want to create another variable for the auto increment number
>> that the database assigned to that new entry.
>>
>> Hope that makes since.
>> Timothy



More information about the UPHPU mailing list