He visto en el manual del mysql y php que haciendo
$oCnx->ping()
se puede verificar si la conexion esta activa/funciona.
Con tdolphin como lo hago?
gracias.
$oCnx->ping()
HB_FUNC( MYSQLPING ) //Zero if the connection to the server is alive. Nonzero if an error occurred
{
int iPing = 1;
MYSQL * hMySQL = (MYSQL *) hb_MYSQL_par( 1 );
if( hMySQL )
{
iPing = mysql_ping( hMySQL );
}
else
{
hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( iPing );
}
HB_FUNC( MYSQLQUERY )
{
MYSQL * hMySQL = (MYSQL *) hb_MYSQL_par( 1 );
if( hMySQL )
{
if( mysql_ping( hMySQL ) == 0 )
{
hb_retnl( ( long ) mysql_real_query( hMySQL,
( const char * ) hb_parc( 2 ),
( unsigned long ) hb_parnl( 3 ) ) ) ;
}
else
{
hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
}
else
{
hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
}
METHOD Ping() INLINE IIf( MySqlPing( ::hMySQL ) > 0, ( ::CheckError(), FALSE ), TRUE )
if ::oCnx:ping()
,,,,,
HB_FUNC( MYSQLCONNECT ) // -> MYSQL*
{
MYSQL * mysql;
unsigned int port = ISNUM( 4 ) ? ( unsigned int ) hb_parni( 4 ) : MYSQL_PORT;
unsigned int flags = ISNUM( 5 ) ? ( unsigned int ) hb_parni( 5 ) : 0;
PHB_ITEM pcbDecrypt = hb_param( 7, HB_IT_BLOCK );
unsigned int * iTimeOut= 10;
BOOL bReconnect = TRUE;
mysql = mysql_init( NULL );
if ( ( mysql != NULL ) )
{
mysql_options( mysql, MYSQL_OPT_RECONNECT , &bReconnect );
mysql_options( mysql, MYSQL_OPT_CONNECT_TIMEOUT, &iTimeOut );
mysql_real_connect( mysql,
hb_itemGetC( hb_vmEvalBlockV( pcbDecrypt, 1, hb_param( 1, HB_IT_ANY ) ) ),
hb_itemGetC( hb_vmEvalBlockV( pcbDecrypt, 1, hb_param( 2, HB_IT_ANY ) ) ),
hb_itemGetC( hb_vmEvalBlockV( pcbDecrypt, 1, hb_param( 3, HB_IT_ANY ) ) ),
hb_itemGetC( hb_vmEvalBlockV( pcbDecrypt, 1, hb_param( 6, HB_IT_ANY ) ) ),
port, NULL, flags );
hb_MYSQL_ret( mysql );
}
else
{
hb_retptr( NULL );
}
}
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 29 guests