From 2c5b2fc105bd6af6571c2bd39d2785c627c6e578 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 26 Feb 2005 17:27:51 +0000 Subject: 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. --- ext/pdo_pgsql/pgsql_driver.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ext/pdo_pgsql/pgsql_driver.c') diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 9134ee769a..72b6781f2d 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -197,15 +197,19 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote return 1; } -static long pdo_pgsql_last_insert_id(pdo_dbh_t *dbh TSRMLS_DC) +static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned int *len TSRMLS_DC) { pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; + char *id = NULL; if (H->pgoid == InvalidOid) { - return -1; + return NULL; } - return (long) H->pgoid; + /* TODO: if name != NULL, pull out last value for that sequence/column */ + + *len = spprintf(&id, 0, "%ld", H->pgoid); + return id; } static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC) -- cgit v1.2.1