diff options
| author | Wez Furlong <wez@php.net> | 2005-02-26 17:27:51 +0000 |
|---|---|---|
| committer | Wez Furlong <wez@php.net> | 2005-02-26 17:27:51 +0000 |
| commit | 2c5b2fc105bd6af6571c2bd39d2785c627c6e578 (patch) | |
| tree | 2f8587ed4b072b8fc8c10e38db4781f6477b53d5 /ext/pdo_mysql/mysql_driver.c | |
| parent | 31239f2130050f8506e08b01ce1364db3a1573ac (diff) | |
| download | php-git-2c5b2fc105bd6af6571c2bd39d2785c627c6e578.tar.gz | |
Alan: moved your fields away, but reserved you a pointer.
Changed PDO::lastInsertId() to have following proto:
string PDO::lastInsertId([string name])
this allows arbitrary unique identitifers to be returned from the driver.
The optional name parameter is for databases that require additional contextual
information to be able to return the correct identifier. None currently use
it, but pgsql will be on the list of drivers that do.
Diffstat (limited to 'ext/pdo_mysql/mysql_driver.c')
| -rwxr-xr-x | ext/pdo_mysql/mysql_driver.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index fe61f55081..cd1c8f0b29 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -160,11 +160,13 @@ static long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM } } -static long pdo_mysql_last_insert_id(pdo_dbh_t *dbh TSRMLS_DC) +static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned int *len, TSRMLS_DC) { pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; + char *id = NULL; - return (long) mysql_insert_id(H->server); + *len = spprintf(&id, 0, "%ld", mysql_insert_id(H->server)); + return id; } static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC) |
