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


PHP pg_ping函数代码示例

本文整理汇总了PHP中pg_ping函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_ping函数的具体用法?PHP pg_ping怎么用?PHP pg_ping使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pg_ping函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ping

 function ping()
 {
     if (!$this->conn) {
         return $this->connect();
     }
     return pg_ping($this->conn);
 }
开发者ID:jvinet,项目名称:pronto,代码行数:7,代码来源:postgresql.php

示例2: is_connected

 public function is_connected()
 {
     return $this->connection_handle && pg_ping($this->connection_handle);
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:4,代码来源:backend-postgresql.lib.php

示例3: reconnect

 /**
  * Reconnect.
  *
  * Keep / reestablish the db connection if no queries have been
  * sent for a length of time exceeding the server's idle timeout
  *
  * @return void
  */
 public function reconnect()
 {
     if (pg_ping($this->conn_id) === false) {
         $this->conn_id = false;
     }
 }
开发者ID:gocanto,项目名称:gocanto-cms,代码行数:14,代码来源:postgre_driver.php

示例4: _check_connect

 /**
  * 检查连接是否可用
  *
  * 防止因长时间不链接而导致连接丢失的问题 server has gone away
  *
  * @throws Exception
  */
 protected function _check_connect()
 {
     # 5秒检测1次
     static $error_num = 0;
     try {
         $connection_id = $this->connection_id();
         $connection = Database_Driver_Postgre::$_connection_instance[$connection_id];
         if ($connection) {
             $ping_status = pg_ping($connection);
         } else {
             $ping_status = false;
         }
     } catch (Exception $e) {
         $error_num++;
         $ping_status = false;
     }
     if (!$ping_status) {
         if ($error_num < 5) {
             $this->close_connect();
             # 等待3毫秒
             usleep(3000);
             # 再次尝试连接
             $this->connect();
             $error_num = 0;
         } else {
             throw new Exception('connect postgre server error');
         }
     }
 }
开发者ID:liuyu121,项目名称:myqee,代码行数:36,代码来源:postgre.class.php

示例5: ping

 /**
  * Checks, if the connection to the server is still alive
  *
  * @return bool
  */
 public function ping()
 {
     // Checks, if the connection to the server is still alive
     if (!$this->objServer) {
         throw new Exception('No SQL resource available. Could not execute ping.');
     }
     return \pg_ping($this->objServer);
 }
开发者ID:dapepe,项目名称:microdb,代码行数:13,代码来源:PostgreSQL.php

示例6: tryOpenDataBase

 /**
  * This function tries to open to the DB
  *
  * @param string $pDbDriver
  * @param array  $arrayServerData
  *
  * @return void
  */
 public function tryOpenDataBase($pDbDriver, array $arrayServerData = array())
 {
     if ($this->errno != 0) {
         return 0;
     }
     set_time_limit(0);
     $stat = new Stat();
     $flagTns = isset($arrayServerData["connectionType"]) && $arrayServerData["connectionType"] == "TNS" ? 1 : 0;
     if (isset($this->db_user) && (isset($this->db_passwd) || $this->db_passwd == "") && (isset($this->db_sourcename) || $flagTns == 1)) {
         switch ($pDbDriver) {
             case 'mysql':
                 $link = @mysql_connect($this->ip . ($this->db_port != '' && $this->db_port != 0 ? ':' . $this->db_port : ''), $this->db_user, $this->db_passwd);
                 $db = @mysql_select_db($this->db_sourcename);
                 if ($link) {
                     if ($db) {
                         $result = @mysql_query("show tables;");
                         if ($result) {
                             $stat->status = 'SUCCESS';
                             $this->errstr = "";
                             $this->errno = 0;
                             @mysql_free_result($result);
                         } else {
                             $this->error = "the user {$this->db_user} doesn't have privileges to run queries!";
                             $this->errstr = "NET::MYSQL->Test query failed";
                             $this->errno = 10100;
                         }
                     } else {
                         $this->error = "The {$this->db_sourcename} data base does'n exist!";
                         $this->errstr = "NET::MYSQL->Select data base failed";
                         $this->errno = 10011;
                     }
                 } else {
                     $this->error = "MySql connection refused!";
                     $this->errstr = "NET::MYSQL->The connection was refused";
                     $this->errno = 10001;
                 }
                 break;
             case 'pgsql':
                 $this->db_port = $this->db_port == "" || $this->db_port == 0 ? "5432" : $this->db_port;
                 $link = @pg_connect("host='{$this->ip}' port='{$this->db_port}' user='{$this->db_user}' password='{$this->db_passwd}' dbname='{$this->db_sourcename}'");
                 if ($link) {
                     if (@pg_ping($link)) {
                         $stat->status = 'SUCCESS';
                         $this->errstr = "";
                         $this->errno = 0;
                     } else {
                         $this->error = "PostgreSql Connection to {$this->ip} is  unreachable!";
                         $this->errstr = "NET::POSTGRES->Lost Connection";
                         $this->errno = 20010;
                     }
                 } else {
                     $this->error = "PostgrSql connection refused";
                     $this->errstr = "NET::POSTGRES->The connection was refused";
                     $this->errno = 20001;
                 }
                 break;
             case 'mssql':
                 //          $str_port = (($this->db_port == "")  || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port;
                 //          $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd);
                 if ($this->db_instance != "") {
                     $str_port = "";
                     $link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
                 } else {
                     $str_port = $this->db_port == "" || $this->db_port == 0 || $this->db_port == 1433 ? "" : ":" . $this->db_port;
                     $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd);
                 }
                 if ($link) {
                     $db = @mssql_select_db($this->db_sourcename, $link);
                     if ($db) {
                         $stat->status = 'SUCCESS';
                         $this->errstr = "";
                         $this->errno = 0;
                     } else {
                         $this->error = "The {$this->db_sourcename} data base does'n exist!";
                         $this->errstr = "NET::MSSQL->Select data base failed";
                         $this->errno = 30010;
                     }
                 } else {
                     $this->error = "MS-SQL Server connection refused!";
                     $this->errstr = "NET::MSSQL->The connection was refused";
                     $this->errno = 30001;
                 }
                 break;
             case 'oracle':
                 if ($flagTns == 0) {
                     $this->db_port = $this->db_port == "" || $this->db_port == 0 ? "1521" : $this->db_port;
                     $cnn = @oci_connect($this->db_user, $this->db_passwd, "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST={$this->ip}) (PORT={$this->db_port}) )) (CONNECT_DATA=(SERVICE_NAME={$this->db_sourcename})))");
                 } else {
                     $cnn = @oci_connect($this->db_user, $this->db_passwd, $arrayServerData["tns"]);
                 }
                 if ($cnn) {
                     $stid = @oci_parse($cnn, 'select AUTHENTICATION_TYPE from v$session_connect_info');
//.........这里部分代码省略.........
开发者ID:norahmollo,项目名称:processmaker,代码行数:101,代码来源:class.net.php

示例7: ping

 public function ping()
 {
     return pg_ping($this->connection);
 }
开发者ID:jasir,项目名称:dbal,代码行数:4,代码来源:PgsqlDriver.php

示例8: check_connection

 /**
  * Check the connection to PgSQL if Active and Not Busy
  * If not connected will connect
  * PRIVATE
  *
  * @param RESOURCE 	$y_connection 				:: The Connection to PgSQL Server
  * @param STRING 	$y_description				:: The Description of Where it is Checked (for having a clue where it fails)
  * @return Connection Resource
  *
  */
 private static function check_connection($y_connection, $y_description)
 {
     //--
     global $configs;
     //--
     if ($y_connection === 'DEFAULT') {
         // just for the default connection !!!
         //--
         if (!defined('SMART_FRAMEWORK_DB_LINK_PostgreSQL')) {
             // PostgreSQL default connection is exported as constant to avoid re-connection which can break transactions
             //--
             if (!is_array($configs['pgsql'])) {
                 self::error('', 'CHECK-DEFAULT-PGSQL-CONFIGS', 'The Default PostgreSQL Configs not detected !', 'The configs[pgsql] is not an array !', $y_description);
                 return null;
             }
             //end if
             if ((string) $configs['pgsql']['server-host'] == '' or (string) $configs['pgsql']['server-port'] == '' or (string) $configs['pgsql']['dbname'] == '' or (string) $configs['pgsql']['username'] == '') {
                 self::error('', 'CHECK-DEFAULT-PGSQL-CONFIGS', 'The Default PostgreSQL Configs are not complete !', 'Some of the configs[pgsql] parameters are missing !', $y_description);
                 return null;
             }
             //end if
             //-- {{{SYNC-CONNECTIONS-IDS}}}
             $the_conn_key = (string) $configs['pgsql']['server-host'] . ':' . $configs['pgsql']['server-port'] . '@' . $configs['pgsql']['dbname'] . '#' . $configs['pgsql']['username'] . '>' . trim(strtoupper(str_replace(' ', '', (string) $configs['pgsql']['transact']))) . '.';
             if (array_key_exists((string) $the_conn_key, (array) SmartFrameworkRegistry::$Connections['pgsql'])) {
                 // if the connection was made before using the SmartPgsqlExtDb
                 //--
                 $y_connection = SmartFrameworkRegistry::$Connections['pgsql'][(string) $the_conn_key];
                 //--
                 define('SMART_FRAMEWORK_DB_LINK_PostgreSQL', $y_connection);
                 //--
                 if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                     SmartFrameworkRegistry::setDebugMsg('db', 'pgsql|log', ['type' => 'open-close', 'data' => 'Re-Using Connection to PgSQL Server as DEFAULT: ' . $the_conn_key, 'connection' => (string) $y_connection]);
                 }
                 //end if
                 //--
             } else {
                 //--
                 $y_connection = self::server_connect((string) $configs['pgsql']['server-host'], (int) $configs['pgsql']['server-port'], (string) $configs['pgsql']['dbname'], (string) $configs['pgsql']['username'], (string) $configs['pgsql']['password'], (int) $configs['pgsql']['timeout'], (string) $configs['pgsql']['transact'], (double) $configs['pgsql']['slowtime'], (string) $configs['pgsql']['type']);
                 //--
                 define('SMART_FRAMEWORK_DB_LINK_PostgreSQL', $y_connection);
                 //--
                 if (is_resource($y_connection)) {
                     //--
                     define('SMART_FRAMEWORK_DB_VERSION_PostgreSQL', self::check_server_version($y_connection, true));
                     // re-validate
                     //--
                 }
                 //end if
                 //--
             }
             //end if else
             //--
         } else {
             //-- re-use the default connection
             $y_connection = SMART_FRAMEWORK_DB_LINK_PostgreSQL;
             //--
         }
         //end if
         //--
     }
     //end if
     //--
     if (!is_resource($y_connection)) {
         // if no connection
         //--
         self::error($y_connection, 'CHECK-CONNECTION', 'Connection is BROKEN !', 'Connection-ID: ' . $y_connection, $y_description);
         return null;
         //--
     }
     //end if
     //--
     if (@pg_connection_status($y_connection) != PGSQL_CONNECTION_OK) {
         //--
         $re_connect = @pg_ping($y_connection);
         //--
         if (!$re_connect) {
             self::error($y_connection, 'CHECK-CONNECTION', 'Connection LOST !', 'Connection-ID: ' . $y_connection, $y_description);
             return null;
         }
         //end if
         //--
     }
     //end if else
     //--
     return $y_connection;
     //--
 }
开发者ID:unix-world,项目名称:Smart.Framework,代码行数:97,代码来源:lib_db_pgsql.php

示例9: ping

 /**
  * Vérifie l'état de la connexion courante et effectue si besoin une reconnexion
  * 
  * @access public
  * @return boolean
  */
 function ping()
 {
     return pg_ping($this->link);
 }
开发者ID:bibwho,项目名称:MATPbootstrap,代码行数:10,代码来源:postgres.php

示例10: ping

 /**
  * transmit a ping against the database
  *
  * @return bool true | false
  */
 public function ping()
 {
     return pg_ping($this->dbh) ? true : false;
 }
开发者ID:andywenk,项目名称:postgresql-php-tools,代码行数:9,代码来源:PgSQL.php

示例11: hasDbConnection

 /**
  * @return bool
  */
 protected function hasDbConnection()
 {
     if ($this->pg_conn) {
         return pg_ping($this->pg_conn);
     } else {
         return pg_ping();
     }
 }
开发者ID:austintoddj,项目名称:php-postgresql-zipcode-class,代码行数:11,代码来源:ZipCode.php

示例12: getProtocolInfo

 public function getProtocolInfo()
 {
     return pg_ping($this->link);
 }
开发者ID:BackupTheBerlios,项目名称:alien-svn,代码行数:4,代码来源:alien_pgsql.php

示例13: pg_connect

<?php

// optional functions
include 'config.inc';
$db = pg_connect($conn_str);
var_dump(pg_ping($db));
开发者ID:badlamer,项目名称:hhvm,代码行数:6,代码来源:19pg_ping.php

示例14: connected

 /**
  * Determines if the connection to the server is active.
  *
  * @return	boolean
  *
  * @since	12.1
  */
 public function connected()
 {
     $this->connect();
     if (is_resource($this->connection)) {
         return pg_ping($this->connection);
     }
     return false;
 }
开发者ID:Rajiii4u,项目名称:joomla-cms,代码行数:15,代码来源:postgresql.php

示例15: isValid

 function isValid()
 {
     return @pg_ping($this->getConnectionId());
 }
开发者ID:snowjobgit,项目名称:limb,代码行数:4,代码来源:lmbPgsqlConnection.class.php


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