summaryrefslogtreecommitdiff
path: root/ext/pdo_pgsql
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2004-05-20 18:00:24 +0000
committerIlia Alshanetsky <iliaa@php.net>2004-05-20 18:00:24 +0000
commitf8d045619a064899f666d132aee6a6b49495d37d (patch)
treeefb12fc86cdd2e76c9a8ec087d523d2d217db71c /ext/pdo_pgsql
parent3ec72d3ed96ceec850e4c446764281b2c39d257e (diff)
downloadphp-git-f8d045619a064899f666d132aee6a6b49495d37d.tar.gz
Last insert id (oids) support.
Diffstat (limited to 'ext/pdo_pgsql')
-rw-r--r--ext/pdo_pgsql/pgsql_driver.c14
-rw-r--r--ext/pdo_pgsql/php_pdo_pgsql_int.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index 67db6fd64e..0036eccb9f 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -117,6 +117,7 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM
pdo_pgsql_error(dbh, qs);
return 0;
}
+ H->pgoid = PQoidValue(res);
}
return 1;
@@ -134,6 +135,16 @@ 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)
+{
+ pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
+
+ if (H->pgoid == InvalidOid) {
+ return -1;
+ }
+
+ return (long) H->pgoid;
+}
static struct pdo_dbh_methods pgsql_methods = {
pgsql_handle_closer,
@@ -144,7 +155,7 @@ static struct pdo_dbh_methods pgsql_methods = {
NULL,
NULL,
NULL,
- NULL,
+ pdo_pgsql_last_insert_id,
pdo_pgsql_fetch_error_func
};
@@ -185,6 +196,7 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
}
H->attached = 1;
+ H->pgoid = -1;
dbh->methods = &pgsql_methods;
dbh->alloc_own_columns = 1;
diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h
index 7d0be93586..27d84277b9 100644
--- a/ext/pdo_pgsql/php_pdo_pgsql_int.h
+++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h
@@ -38,6 +38,7 @@ typedef struct {
unsigned attached:1;
unsigned _reserved:31;
pdo_pgsql_error_info einfo;
+ Oid pgoid;
} pdo_pgsql_db_handle;
typedef struct {