php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #8786 odbc_insert_id()
Submitted: 2001-01-18 11:19 UTC Modified: 2001-01-18 11:29 UTC
From: stuarth at generalsearch dot net Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS: Any
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: stuarth at generalsearch dot net
New email:
PHP Version: OS:

 

 [2001-01-18 11:19 UTC] stuarth at generalsearch dot net
Some way of accessing the most recently-inserted row would be very useful.  This could be done either by an odbc version of mysql_insert_id(), or (preferably) odbc_exec() returning a pointer to the newly-inserted row so that odbc_fetch_row() and odbc_fetch_into() can retrieve the data.

I need this because I need to access any identity fields (the closest mysql equivalent is auto_increment) that were created during an insert since I tend to use these as keys and have foreign keys in other tables pointing to them.

The 2nd way is preferable because it ensures that a very busy SQL server will not return any inserts that may have been done in between the insert command and the odbc_insert_id() command.  (Even if they're back-to-back, you may still have an insert sneak in between if the server is constantly being accessed.)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-18 11:29 UTC] kara@php.net
There is no way to get this information through ODBC.

A possible solution could be to wrap your inserts into a
stored procedure (more exactly function) that does the
INSERT and returns the desired information.

Or simply use sequences, if your database supports this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 22:01:26 2024 UTC