List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 26 1999 2:53pm
Subject:Re: AUTOINCREMENT & INSERT ...
View as plain text  
No, it returns a scalar value representing that last AUTO_INCREMENT value
that was generated for your current server connection.


At 9:11 AM -0500 5/26/99, Sandrine C. wrote:
>Just a question about mysql_insert_db().. I m curious
>how does it work if the primary key is composed of more than one field??
>Does it retunr you an array??
>
>Sandrine
>
>
>>I asked this too once: You're looking for mysql_insert_id() which will
>>return the previously created autoincrement key. I.e.
>>
>>   $add_adresses=mysql_query("INSERT INTO adresse VALUES(NULL, ...");
>>   $id=mysql_insert_id();
>>   $add_other=mysql_query("INSERT INTO other VALUES(NULL, ...,$id,...");
>>   $other_id=mysql_insert_id();
>>   mysql_query("update adresse set thefield='$other_id' where id='$id'");
>>
>>Hope this is what You need.
>>   Erik L.
>>
>>---
>>Erik Liljencrantz, E-ell-Data, http://www.eldata.se
>>erik@stripped, +46 150 250 58, +46 70 51 8 51 26
>>Aspenaes, 640 25 JULITA, SWEDEN

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
AUTOINCREMENT & INSERT ...Sandrine C.26 May
  • Re: AUTOINCREMENT & INSERT ...Erik Liljencrantz26 May
Re: AUTOINCREMENT & INSERT ...jkraai26 May
Re: AUTOINCREMENT & INSERT ...Sandrine C.26 May
  • Re: AUTOINCREMENT & INSERT ...Paul DuBois26 May
    • CHAR and VARCHARRitschie26 May
      • Re: CHAR and VARCHARSasha Pachev26 May
      • Re: CHAR and VARCHARJim Faucette26 May
Re: AUTOINCREMENT & INSERT ...Nick Rawlings27 May