summaryrefslogtreecommitdiff
path: root/ext/pgsql/pgsql.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-07-22 23:05:17 +0000
committerMarcus Boerger <helly@php.net>2003-07-22 23:05:17 +0000
commit7a85edd370de9833689806dc059cad672232b9d4 (patch)
tree25c1ce1c127d97e91f97c38f2a6d725d0b31c07d /ext/pgsql/pgsql.c
parentec9ae45e2f322ac954209323f0b31cece11f6c76 (diff)
downloadphp-git-7a85edd370de9833689806dc059cad672232b9d4.tar.gz
Added pg_version() which returns an associative array of client/protocol/server
version. @Added pg_version() function. (Marcus)
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r--ext/pgsql/pgsql.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index da39607302..1fa16651a5 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -88,6 +88,7 @@ function_entry pgsql_functions[] = {
PHP_FE(pg_port, NULL)
PHP_FE(pg_tty, NULL)
PHP_FE(pg_options, NULL)
+ PHP_FE(pg_version, NULL)
PHP_FE(pg_ping, NULL)
/* query functions */
PHP_FE(pg_query, NULL)
@@ -782,6 +783,7 @@ PHP_FUNCTION(pg_close)
#define PHP_PG_PORT 4
#define PHP_PG_TTY 5
#define PHP_PG_HOST 6
+#define PHP_PG_VERSION 7
/* {{{ php_pgsql_get_link_info
*/
@@ -831,6 +833,18 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type
case PHP_PG_HOST:
Z_STRVAL_P(return_value) = PQhost(pgsql);
break;
+ case PHP_PG_VERSION:
+ array_init(return_value);
+ add_assoc_string(return_value, "client", PG_VERSION, 1);
+#if HAVE_PQPROTOCOLVERSION
+ add_assoc_long(return_value, "protocol", PQprotocolVersion(pgsql));
+#if HAVE_PQPARAMETERSTATUS
+ if (PQprotocolVersion(pgsql) >= 3) {
+ add_assoc_string(return_value, "server", PQparameterStatus(pgsql, "server_version"), 1);
+ }
+#endif
+#endif
+ return;
default:
RETURN_FALSE;
}
@@ -893,6 +907,14 @@ PHP_FUNCTION(pg_host)
}
/* }}} */
+/* {{{ proto array pg_version([resource connection])
+ Returns an array with client, protocol and server version (when available) */
+PHP_FUNCTION(pg_version)
+{
+ php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_VERSION);
+}
+/* }}} */
+
/* {{{ proto bool pg_ping(resource connection)
Ping database. If connection is bad, try to reconnect. */
PHP_FUNCTION(pg_ping)