mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Added pg_version() which returns an associative array of client/protocol/server
version. @Added pg_version() function. (Marcus)
This commit is contained in:
parent
ec9ae45e2f
commit
7a85edd370
3 changed files with 25 additions and 0 deletions
|
@ -57,6 +57,8 @@ if test "$PHP_PGSQL" != "no"; then
|
|||
AC_CHECK_LIB(pq, PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES,1,[Broken libpq under windows]))
|
||||
AC_CHECK_LIB(pq, PQoidValue,AC_DEFINE(HAVE_PQOIDVALUE,1,[Older PostgreSQL]))
|
||||
AC_CHECK_LIB(pq, PQclientEncoding,AC_DEFINE(HAVE_PQCLIENTENCODING,1,[PostgreSQL 7.0.x or later]))
|
||||
AC_CHECK_LIB(pq, PQparameterStatus,AC_DEFINE(HAVE_PQPARAMETERSTATUS,1,[PostgreSQL 7.4 or later]))
|
||||
AC_CHECK_LIB(pq, PQprotocolVersion,AC_DEFINE(HAVE_PQPROTOCOLVERSION,1,[PostgreSQL 7.4 or later]))
|
||||
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibye]))
|
||||
LIBS=$old_LIBS
|
||||
LDFLAGS=$old_LDFLAGS
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -71,6 +71,7 @@ PHP_FUNCTION(pg_dbname);
|
|||
PHP_FUNCTION(pg_port);
|
||||
PHP_FUNCTION(pg_tty);
|
||||
PHP_FUNCTION(pg_options);
|
||||
PHP_FUNCTION(pg_version);
|
||||
PHP_FUNCTION(pg_ping);
|
||||
/* query functions */
|
||||
PHP_FUNCTION(pg_query);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue