@@ -317,6 +317,9 @@ ZEND_END_ARG_INFO()
317317ZEND_BEGIN_ARG_INFO_EX (arginfo_ibase_free_event_handler , 0 , 0 , 1 )
318318 ZEND_ARG_INFO (0 , event )
319319ZEND_END_ARG_INFO ()
320+
321+ ZEND_BEGIN_ARG_INFO (arginfo_ibase_get_client_version , 0 )
322+ ZEND_END_ARG_INFO ()
320323/* }}} */
321324
322325/* {{{ extension definition structures */
@@ -378,6 +381,8 @@ static const zend_function_entry ibase_functions[] = {
378381 PHP_FE (ibase_set_event_handler , arginfo_ibase_set_event_handler )
379382 PHP_FE (ibase_free_event_handler , arginfo_ibase_free_event_handler )
380383
384+ PHP_FE (ibase_get_client_version , arginfo_ibase_get_client_version )
385+
381386 /**
382387 * These aliases are provided in order to maintain forward compatibility. As Firebird
383388 * and InterBase are developed independently, functionality might be different between
@@ -441,6 +446,8 @@ static const zend_function_entry ibase_functions[] = {
441446 PHP_FALIAS (fbird_wait_event , ibase_wait_event , arginfo_ibase_wait_event )
442447 PHP_FALIAS (fbird_set_event_handler , ibase_set_event_handler , arginfo_ibase_set_event_handler )
443448 PHP_FALIAS (fbird_free_event_handler , ibase_free_event_handler , arginfo_ibase_free_event_handler )
449+
450+ PHP_FALIAS (fbird_get_client_version , ibase_get_client_version , arginfo_ibase_get_client_version )
444451 PHP_FE_END
445452};
446453
@@ -491,6 +498,18 @@ PHP_FUNCTION(ibase_errmsg)
491498}
492499/* }}} */
493500
501+ /* {{{ proto float ibase_get_client_version(void)
502+ Return client version in form major.minor */
503+ PHP_FUNCTION (ibase_get_client_version )
504+ {
505+ if (zend_parse_parameters_none () == FAILURE ) {
506+ return ;
507+ }
508+
509+ RETURN_DOUBLE ((double )IBG (client_major_version ) + (double )IBG (client_minor_version ) / 10 );
510+ }
511+ /* }}} */
512+
494513/* {{{ proto int ibase_errcode(void)
495514 Return error code */
496515PHP_FUNCTION (ibase_errcode )
@@ -811,8 +830,20 @@ static PHP_GINIT_FUNCTION(ibase)
811830 ibase_globals -> num_persistent = ibase_globals -> num_links = 0 ;
812831 ibase_globals -> sql_code = * ibase_globals -> errmsg = 0 ;
813832 ibase_globals -> default_link = NULL ;
814- ibase_globals -> fb_get_master_interface = _php_ibase_get_fbclient_symbol ("fb_get_master_interface" );
815- ibase_globals -> fb_get_statement_interface = _php_ibase_get_fbclient_symbol ("fb_get_statement_interface" );
833+ ibase_globals -> get_master_interface = _php_ibase_get_fbclient_symbol ("fb_get_master_interface" );
834+ ibase_globals -> get_statement_interface = _php_ibase_get_fbclient_symbol ("fb_get_statement_interface" );
835+
836+ if (ibase_globals -> get_master_interface ) {
837+ ibase_globals -> master_instance = ((fb_get_master_interface_t )(ibase_globals -> get_master_interface ))();
838+ ibase_globals -> client_version = fb_get_client_version (ibase_globals -> master_instance );
839+ ibase_globals -> client_major_version = ibase_globals -> client_version >> 8 ;
840+ ibase_globals -> client_minor_version = ibase_globals -> client_version & 0xFF ;
841+ } else {
842+ ibase_globals -> master_instance = NULL ;
843+ ibase_globals -> client_version = -1 ;
844+ ibase_globals -> client_major_version = -1 ;
845+ ibase_globals -> client_minor_version = -1 ;
846+ }
816847}
817848
818849PHP_MINIT_FUNCTION (ibase )
0 commit comments