当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli_ping函数代码示例

本文整理汇总了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);
    }
}
开发者ID:pandalion98,项目名称:cluebotng,代码行数:7,代码来源:mysql_functions.php

示例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;
     }
 }
开发者ID:packetlost,项目名称:OpenCart-Overclocked,代码行数:29,代码来源:upgrade.php

示例3: isOpen

 /**
  * is this connection open
  * @return boolean
  */
 public function isOpen()
 {
     if ($this->connection == null) {
         return false;
     }
     return mysqli_ping($this->connection);
 }
开发者ID:richyguitar,项目名称:mosd,代码行数:11,代码来源:dbconnection.php

示例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;
 }
开发者ID:emente,项目名称:kataii---kata-framework-2.x,代码行数:10,代码来源:dbo_mysqli.php

示例5: check_reconnect

 private function check_reconnect()
 {
     if (!mysqli_ping($this->conn)) {
         if (!$this->connect()) {
             throw new Exception('Error reconnect.');
         }
     }
 }
开发者ID:WattyRev,项目名称:games,代码行数:8,代码来源:mysqli.php

示例6: ping

 private function ping()
 {
     if (!@mysqli_ping(self::$socket)) {
         tools::log('ping timeout database connection');
         self::disconnect();
         self::connect();
     }
 }
开发者ID:derkalle4,项目名称:gamespy-loginserver,代码行数:8,代码来源:database.php

示例7: ping

 public function ping()
 {
     $mysqli = $this->connection;
     if (mysqli_ping($mysqli)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:nikola993,项目名称:task8,代码行数:9,代码来源:mysql.php

示例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;
 }
开发者ID:sinfini,项目名称:checkpoint,代码行数:10,代码来源:Connection.php

示例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;
 }
开发者ID:r2git,项目名称:icms1,代码行数:14,代码来源:db.class.php

示例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;
 }
开发者ID:Germancito,项目名称:fofBackend,代码行数:53,代码来源:functions.php

示例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;
     }
 }
开发者ID:sabalbhati,项目名称:DiscoverMoreMusic,代码行数:14,代码来源:db.class.php

示例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('数据库连接失败');
     }
 }
开发者ID:joyerma,项目名称:yongzhuo,代码行数:14,代码来源:mysqli.php

示例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));
     }
 }
开发者ID:inEdgar,项目名称:prestamo-para-negocio_proyecto,代码行数:15,代码来源:Conexionppn.php

示例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;
 }
开发者ID:asalem,项目名称:collections,代码行数:20,代码来源:DB.php

示例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;
     }
 }
开发者ID:myqee,项目名称:database-mysqli,代码行数:22,代码来源:Driver.php


注:本文中的mysqli_ping函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。