diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2006-01-29 17:36:12 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2006-01-29 17:36:12 +0000 |
commit | b90245d90aebf3d0173b22048e9c25793fe3aa8f (patch) | |
tree | b30dcae754097ea231163ad850559429d4768461 | |
parent | 3bed27f4a685b821c7e453e6210de3cbe853863a (diff) | |
download | php-git-b90245d90aebf3d0173b22048e9c25793fe3aa8f.tar.gz |
MFB51: Fixed bug #36176 (PDO_PGSQL - PDO::exec() does not return number of
rows affected by the operation).
-rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index a7ec1647e7..74e59eaf8b 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -222,23 +222,26 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM { pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; PGresult *res; + long ret = 1; if (!(res = PQexec(H->server, sql))) { /* fatal error */ pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); return -1; - } else { - ExecStatusType qs = PQresultStatus(res); - if (qs != PGRES_COMMAND_OK && qs != PGRES_TUPLES_OK) { - pdo_pgsql_error(dbh, qs, pdo_pgsql_sqlstate(res)); - PQclear(res); - return -1; - } - H->pgoid = PQoidValue(res); + } + ExecStatusType qs = PQresultStatus(res); + if (qs != PGRES_COMMAND_OK && qs != PGRES_TUPLES_OK) { + pdo_pgsql_error(dbh, qs, pdo_pgsql_sqlstate(res)); PQclear(res); + return -1; } + H->pgoid = PQoidValue(res); +#if HAVE_PQCMDTUPLES + ret = atol(PQcmdTuples(res)); +#endif + PQclear(res); - return 1; + return ret; } static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC) |