PHP8 cubrid_ping
(PECL CUBRID >= 8.3.1)
cubrid_ping — Ping 服务器连接或在没有连接时重新连接
说明
cubrid_ping(resource $conn_identifier = ?): bool
检查与服务器的连接是否正常工作。
参数
conn_identifier
CUBRID 连接标识符。如果连接标识符不是 指定后,假定 cubrid_connect() 打开的最后一个连接。
返回值
如果与服务器 CUBRID 服务器的连接正常工作,则返回 true,否则返回 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);
?>