Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.4.0 |  CUBRID 8.4.1 | 



cubrid_ping

Description

The cubrid_ping function pings a server connection or reconnection if there is no connection.

Syntax

bool cubrid_ping ([resource $conn_identifier ])

  • conn_identifier : Connection identifier. If the connection identifier is not specified, the last connection is assumed.
Return Value
  • If the connection to the database server is working : TRUE
  • Otherwise : FALSE
Example

<?php

set_time_limit(0);

 

$conn = cubrid_connect('localhost', 33000, 'demodb');

 

/* Assuming this query will take a long time */

$result = cubrid_query($sql);

if (!$result) {

    echo 'Query #1 failed, exiting.';

    exit;

}

 

/* Make sure the connection is still alive, if not, try to reconnect */

if (!cubrid_ping($conn)) {

    echo 'Lost connection, exiting after query #1';

    exit;

}

cubrid_free_result($result);

 

/* So the connection is still alive, let's run another query */

$result2 = cubrid_query($sql2);

?>