本文整理汇总了PHP中mysqli_ping函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_ping函数的具体用法?PHP mysqli_ping怎么用?PHP mysqli_ping使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_ping函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkRepMySQL
function checkRepMySQL()
{
if (!Globals::$mw_mysql or !mysqli_ping(Globals::$mw_mysql)) {
Globals::$mw_mysql = mysqli_connect('p:' . Config::$mw_mysql_host, Config::$mw_mysql_user, Config::$mw_mysql_pass, Config::$mw_mysql_db, Config::$mw_mysql_port);
mysqli_select_db(Globals::$mw_mysql, Config::$mw_mysql_db);
}
}
示例2: validate
private function validate()
{
if (DB_DRIVER == 'mysql') {
if (!($connection = @mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD))) {
$this->error['warning'] = $this->language->get('error_db_connect');
} else {
if (!mysql_select_db(DB_DATABASE, $connection)) {
$this->error['warning'] = 'Error: Database "' . DB_DATABASE . '" does not exist!';
}
mysql_close($connection);
}
}
if (DB_DRIVER == 'mysqli') {
$link = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if (mysqli_connect_errno()) {
$this->error['warning'] = 'Error database connect: "' . mysqli_connect_error() . '"';
exit;
}
if (!mysqli_ping($link)) {
$this->error['warning'] = 'Error database server: "' . mysqli_error($link) . '"';
}
mysqli_close($link);
}
if (!$this->error) {
return true;
} else {
return false;
}
}
示例3: isOpen
/**
* is this connection open
* @return boolean
*/
public function isOpen()
{
if ($this->connection == null) {
return false;
}
return mysqli_ping($this->connection);
}
示例4: getLink
/**
* return the current link to the database, connect first if needed
*/
public function getLink()
{
if (!mysqli_ping($this->link)) {
$this->connect();
}
return $this->link;
}
示例5: check_reconnect
private function check_reconnect()
{
if (!mysqli_ping($this->conn)) {
if (!$this->connect()) {
throw new Exception('Error reconnect.');
}
}
}
示例6: ping
private function ping()
{
if (!@mysqli_ping(self::$socket)) {
tools::log('ping timeout database connection');
self::disconnect();
self::connect();
}
}
示例7: ping
public function ping()
{
$mysqli = $this->connection;
if (mysqli_ping($mysqli)) {
return true;
} else {
return false;
}
}
示例8: reConnect
function reConnect()
{
//return true;
if (is_null(self::$db) || !mysqli_ping(self::$db)) {
Log::info(date('Y-m-d h:iA') . ': Lost connection, with error: ' . mysqli_error(self::$db) . ',connecting..');
$this->disconnect();
return $this->connect();
}
return true;
}
示例9: reinitializedConnection
/**
* Реинициализирует соединение с базой
*/
public static function reinitializedConnection()
{
$db = self::getInstance();
if (!mysqli_ping($db->db_link)) {
if (!empty($db->db_link)) {
mysqli_close($db->db_link);
}
$db->db_link = self::initConnection();
}
return true;
}
示例10: showFriends
function showFriends($steamID)
{
/*
@this function will retrieve the users friends list from steam
@then it will compare it to our tables. if the friend is in the database
@it will pull it from there and display it
@otherwise it will add it to the database then pull it.
*/
$apikey1 = "238E8D6B70BF7499EE36312EF39F91AA";
$pushFriends = "http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key={$apikey1}&steamid={$steamID}&relationship=friend";
//echo "addFriends initialized";
//echo $apikey1;
$jsonList = file_get_contents($pushFriends);
$json_decode = json_decode($jsonList);
//echo $json_decode->friendslist->friends[0]->steamid;
$db1 = mysqli_connect("localhost", "root", "password", "profile");
if (!mysqli_ping($db1)) {
echo 'Lost connection, exiting after query #1';
exit;
}
//$i=0;
$friendArray = array();
foreach ($json_decode->friendslist->friends as $friend) {
$friendID = $friend->steamid;
//echo $friendID;
$sql_fetch_id = "SELECT * FROM users WHERE steamid = {$friendID}";
$query_id = mysqli_query($db1, $sql_fetch_id);
//echo $friendID;
if (mysqli_num_rows($query_id) > 0) {
//echo "true";
$sql_fetch_avatar = "SELECT avatar FROM users WHERE steamid = {$friendID}";
$sql_fetch_id = "SELECT steamid FROM users WHERE steamid = {$friendID}";
$sql_fetch_name = "SELECT name FROM users WHERE steamid = {$friendID}";
$query_avatar = mysqli_query($db1, $sql_fetch_avatar);
$row_avatar = mysqli_fetch_assoc($query_avatar);
//$query_id= mysqli_query($db1,$sql_fetch_id);
//$row_id=mysqli_fetch_assoc($query_id);
$query_name = mysqli_query($db1, $sql_fetch_name);
$row_name = mysqli_fetch_assoc($query_name);
$avatar = $row_avatar["avatar"];
//$fID=$row_avatar["id"];
$fName = $row_name["name"];
array_push($friendArray, $avatar, $fName);
//echo "<img src=$avatar>";
//echo "\r\n";
//echo $fName;
//echo "<br>";
} else {
addFriendsToUsers($steamID);
}
}
return $friendArray;
}
示例11: pingServer
public function pingServer()
{
$connectionOpen = true;
try {
if ($this->config->connector == "mysqli") {
if (!mysqli_ping($this->connection)) {
$connectionOpen = false;
}
return $connectionOpen;
}
} catch (exception $e) {
return $e;
}
}
示例12: check_connect
private function check_connect()
{
if (!$this->conn || !is_object($this->conn)) {
$this->connect();
} else {
if (!mysqli_ping($this->conn)) {
mysqli_close($this->conn);
$this->connect();
}
}
if (!$this->conn || !is_object($this->conn)) {
$this->error('数据库连接失败');
}
}
示例13: __construct
function __construct()
{
$this->conexion = mysqli_connect($this->host, $this->user, $this->pass, $this->database);
//mysql_select_db($this->database);
mysqli_query($this->conexion, "SET NAMES 'utf8'");
if (mysqli_connect_errno()) {
printf("Conexión fallida: %s\n", mysqli_connect_error());
exit;
}
if (mysqli_ping($this->conexion)) {
echo "Conexion establecida";
} else {
printf("Error: ", mysqli_error($this->conexion));
}
}
示例14: Connect
/**
* Create a DB Connection
*
* @return DB
*/
public static function Connect($dbIp, $dbUserName, $dbPassword, $dbName)
{
if (is_array(self::$instances)) {
foreach (self::$instances as $instance) {
if ($instance instanceof DB && $dbIp == $instance->dbIp && $dbName == $instance->dbName) {
if (mysqli_ping($instance->connection)) {
return $instance;
}
}
}
}
$return = new DB($dbIp, $dbUserName, $dbPassword, $dbName);
//self::$instances[] = $return;
return $return;
}
示例15: checkConnect
/**
* 检查连接(每5秒钟间隔才检测)
*
* @param $id
* @param int $limit 时间间隔(秒), 0 表示一直检查
* @return bool
*/
protected function checkConnect($id, $limit = 5)
{
$tmp = $this->connections[$id];
if (0 === $limit || time() - $tmp['time'] > $limit) {
if (\mysqli_ping($tmp['resource'])) {
return true;
} else {
# 自动移除失败的连接
$this->release($id);
return false;
}
} else {
return true;
}
}