Switch to: V11V10V9V8V7V6V5

valentina_ping()

Declaration

bool valentina_ping ( [resource link_identifier] )

Parameters

Name Description
link_identifierThe Valentina connection. If the link identifier is not specified, the last link opened by valentina_connect() is assumed. If by chance no connection is found, an E_WARNING level warning is generated.

Description

Checks whether or not the connection to the server is working. This function can be used by scripts that remain idle for a long while, to check whether or not the server has closed the connection.

Return Values

Returns TRUE if the connection to the server Valentina server is working, otherwise FALSE.

Examples

Example 1.

<?php
set_time_limit(0);
 
$conn = valentina_connect('localhost', 'valluser', 'mypass');
$db  = valentina_select_db('mydb');
 
/* Assuming this query will take a long time */
$result = valentina_query($sql);
if (!$result) {
   echo 'Query #1 failed, exiting.';
   exit;
}
 
/* Make sure the connection is still alive, if not, try to reconnect */
if (!valentina_ping($conn)) {
   echo 'Lost connection, exiting after query #1';
   exit;
}
valentina_free_result($result);
 
/* So the connection is still alive, let's run another query */
$result2 = valentina_query($sql2);
?>