v5:reference:connection:insert_id
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
reference:insert_id [2015/12/09 01:12] – mnewnham | v5:reference:connection:insert_id [2019/07/08 22:20] – mnewnham | ||
---|---|---|---|
Line 11: | Line 11: | ||
The function '' | The function '' | ||
- | It is important to remember | + | The value retrieved |
- | The only drivers | + | It is important to remember |
===== Usage ===== | ===== Usage ===== | ||
Line 25: | Line 25: | ||
* Insert into table with auto-increment column, current highest value 100 | * Insert into table with auto-increment column, current highest value 100 | ||
*/ | */ | ||
- | $db->Execute(' | + | $db->execute(' |
$lastId = $db-> | $lastId = $db-> | ||
print $lastId; | print $lastId; | ||
/* | /* | ||
* returns value 101 | * returns value 101 | ||
+ | */ | ||
+ | |||
+ | /* | ||
+ | * Insert into a different table with auto-increment, | ||
+ | */ | ||
+ | $db-> | ||
+ | $lastId = $db-> | ||
+ | print $lastId; | ||
+ | /* | ||
+ | * returns value 51, There is now no way of retrieving the previous last id | ||
*/ | */ | ||
</ | </ | ||
+ | |||
+ | ===== Oracle Using Emulated Sequences ===== | ||
+ | If you use the emulated sequence function with the [[v5: | ||
+ | |||
+ | <code php> | ||
+ | |||
+ | /* | ||
+ | * Oracle Connection assumed | ||
+ | */ | ||
+ | $sequence = insertId(' | ||
+ | </ | ||
+ | |||
+ | For that reason, the usage rules about a single instance do not apply. However if you are writing cross-database code you should follow those rules. | ||
+ | |||
+ | ===== Postgresql / SAP MaxDB ===== | ||
+ | |||
+ | The only drivers that __require__ the optional '' | ||
+ | |||
+ |
v5/reference/connection/insert_id.txt · Last modified: 2023/06/20 09:40 by dregad