Ping a server connection or reconnect if there is no connection

cubrid_ping

(PECL CUBRID >= 8.3.1)

cubrid_pingPing a server connection or reconnect if there is no connection

說明

cubrid_ping(resource $conn_identifier = ?): bool

Checks whether or not the connection to the server is working.

參數

conn_identifier

The CUBRID connection identifier. If the connection identifier is not specified, the last connection opened by cubrid_connect() is assumed.

返回值

Returns true if the connection to the server CUBRID server is working, otherwise false.

範例

示例 #1 cubrid_ping() example

<?php
set_time_limit
(0);

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

/* Assuming this query will take a long time */
$sql "select * from athlete";
$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 */
$sql2 "select * from code";
$result2 cubrid_query($sql2);
?>

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *