• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pg_pconnect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: conectar

 function conectar($server = IP_SERVER, $user = USER_DB, $pass = PASSWORD_DB, $based = DB, $puerto = PORT, $tipo_conexion = "N")
 {
     try {
         switch ($tipo_conexion) {
             case "N":
                 // Conexion a B.D no persistente
                 $this->id_conexion = @pg_connect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}");
                 break;
             case "P":
                 // Conexion a B.D persistente
                 $this->id_conexion = @pg_pconnect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}");
                 break;
             default:
                 // Otros casos
                 $this->id_conexion = @pg_connect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}");
                 break;
         }
         if ($this->id_conexion) {
             //$this->id_conexion->set_charset(CODEC);
             return $this->id_conexion;
         } else {
             throw new Exception("Error 01: " . ($this->id_conexion ? pg_error($this->id_conexion) : 'Servidor o B.D. no disponible'));
         }
     } catch (Exception $e) {
         $this->error1 = $e->getMessage();
         return null;
     }
 }
开发者ID:edmalagon,项目名称:operlog,代码行数:28,代码来源:posgresql.class.php


示例2: connect

 public function connect()
 {
     if ($this->bConnected) {
         return $this->rConnection;
     }
     $iLevel = error_reporting();
     // to suppress E_WARNING that can happen
     error_reporting(0);
     if ($this->iPersistence == 0) {
         // plain connect
         $this->rConnection = pg_connect($this->sConnString, PGSQL_CONNECT_FORCE_NEW);
     } else {
         if ($this->iPersistence == 1) {
             // persistent connect
             $this->rConnection = pg_pconnect($this->sConnString);
         } else {
             if ($this->iPersistence == PGSQL_CONNECT_FORCE_NEW) {
                 // persistent connect forced new
                 $this->rConnection = pg_connect($this->sConnString, PGSQL_CONNECT_FORCE_NEW);
             }
         }
     }
     // lets restore previous level
     error_reporting($iLevel);
     $iConnStatus = pg_connection_status($this->rConnection);
     if ($iConnStatus !== PGSQL_CONNECTION_OK) {
         if (is_resource($this->rConnection)) {
             pg_close($this->rConnection);
         }
         throw new \Exception('Unable to connect.');
     }
     $this->bConnected = true;
     return $this->rConnection;
 }
开发者ID:denismilovanov,项目名称:libpostgres,代码行数:34,代码来源:LibPostgresDriver.php


示例3: _connect

 protected function _connect()
 {
     $connstr = '';
     foreach ($this->_config as $param => $value) {
         if ($value) {
             switch ($param) {
                 case 'host':
                     $connstr .= "host={$value} ";
                     break;
                 case 'database':
                     $connstr .= "dbname={$value} ";
                     break;
                 case 'port':
                     $connstr .= "port={$value} ";
                     break;
                 case 'username':
                     $connstr .= "user={$value} ";
                     break;
                 case 'password':
                     $connstr .= "password={$value} ";
                     break;
             }
         }
     }
     if (isset($this->_config['persistent'])) {
         $this->_connection = pg_pconnect($connstr);
     } else {
         $this->_connection = pg_connect($connstr);
     }
     if (pg_connection_status($this->_connection) !== PGSQL_CONNECTION_OK) {
         $this->_errorHandler(1, "Cconnection failed. ");
     }
 }
开发者ID:TheProjecter,项目名称:skeleton,代码行数:33,代码来源:Postgres.php


示例4: connect

 function connect()
 {
     $this->close();
     $p = $this->params;
     $connstr = "dbname={$p['name']}";
     if ($p['user']) {
         $connstr .= " user={$p['user']}";
     }
     if ($p['pass']) {
         $connstr .= " password={$p['pass']}";
     }
     if ($p['host']) {
         $connstr .= " host={$p['host']}";
     }
     if ($p['port']) {
         $connstr .= " port={$p['port']}";
     }
     if ($p['persistent']) {
         $this->conn = pg_pconnect($connstr);
     } else {
         $this->conn = pg_connect($connstr);
     }
     if (!$this->conn) {
         $this->_catch("Unable to connect to the database: " . pg_last_error());
         return false;
     }
     return true;
 }
开发者ID:jvinet,项目名称:pronto,代码行数:28,代码来源:postgresql.php


示例5: open

 public function open()
 {
     if (!$this->handle) {
         if (!$this->port) {
             $this->port = 5432;
         }
         $str_conn = "host={$this->server} port={$this->port} dbname={$this->source} user={$this->user} password={$this->pass}";
         if ($this->persistent) {
             $this->handle = pg_pconnect($str_conn);
         } else {
             $this->handle = pg_connect($str_conn);
         }
         if (!$this->handle) {
             $this->connection_error(pg_last_error());
             $this->handle = false;
             return false;
         }
         // Keep track of the number of connections we create
         $this->increment_counters();
     }
     // Flag Connection as Open
     $this->conn_open = true;
     // Start Transaction?
     if (!$this->auto_commit && !$this->trans_started) {
         $this->start_trans();
     }
     return true;
 }
开发者ID:codifyllc,项目名称:phpopenfw,代码行数:28,代码来源:dt_pgsql.class.php


示例6: connect

 function connect()
 {
     global $php_errormsg;
     $persistent = isset($this->config['persistent']) ? $this->config['persistent'] : null;
     $connstr = '';
     if ($host = $this->config['host']) {
         $connstr = 'host=' . $host;
     }
     if ($port = $this->config['port']) {
         $connstr .= ' port=' . $port;
     }
     if ($database = $this->config['database']) {
         $connstr .= ' dbname=\'' . addslashes($database) . '\'';
     }
     if ($user = $this->config['user']) {
         $connstr .= ' user=\'' . addslashes($user) . '\'';
     }
     if ($password = $this->config['password']) {
         $connstr .= ' password=\'' . addslashes($password) . '\'';
     }
     if ($persistent) {
         $conn = @pg_pconnect($connstr);
     } else {
         $conn = @pg_connect($connstr);
     }
     if (!is_resource($conn)) {
         $this->_raiseError($php_errormsg);
     }
     if (isset($this->config['charset']) && ($charset = $this->config['charset'])) {
         pg_set_client_encoding($conn, $charset);
     }
     $this->connectionId = $conn;
 }
开发者ID:snowjobgit,项目名称:limb,代码行数:33,代码来源:lmbPgsqlConnection.class.php


示例7: connect

 public function connect($config = [])
 {
     $this->config = $config;
     $dsn = 'host=' . $this->config['host'] . ' ';
     if (!empty($this->config['port'])) {
         $dsn .= 'port=' . $this->config['port'] . ' ';
     }
     if (!empty($this->config['database'])) {
         $dsn .= 'dbname=' . $this->config['database'] . ' ';
     }
     if (!empty($this->config['user'])) {
         $dsn .= 'user=' . $this->config['user'] . ' ';
     }
     if (!empty($this->config['password'])) {
         $dsn .= 'password=' . $this->config['password'] . ' ';
     }
     if (!empty($this->config['dsn'])) {
         $dsn = $this->config['dsn'];
     }
     $dsn = rtrim($dsn);
     $this->connect = $this->config['pconnect'] === true ? @pg_pconnect($dsn) : @pg_connect($dsn);
     if (empty($this->connect)) {
         die(getErrorMessage('Database', 'connectError'));
     }
     if (!empty($this->config['charset'])) {
         pg_set_client_encoding($this->connect, $this->config['charset']);
     }
 }
开发者ID:znframework,项目名称:znframework,代码行数:28,代码来源:Postgres.php


示例8: db_connect

/**
 *  db_connect() - Connect to the database
 *  Notice the global vars that must be set up
 *  Sets up a global $gfconn variable which is used 
 *  in other functions in this library.
 */
function db_connect()
{
    global $sys_dbhost, $sys_dbuser, $sys_dbpasswd, $gfconn, $sys_dbname, $sys_db_use_replication, $sys_dbport, $sys_dbreaddb, $sys_dbreadhost;
    //
    //	Connect to primary database
    //
    if (function_exists("pg_pconnect")) {
        $gfconn = pg_pconnect(pg_connectstring($sys_dbname, $sys_dbuser, $sys_dbpasswd, $sys_dbhost, $sys_dbport));
    } else {
        print "function pg_pconnect doesn't exist: no postgresql interface";
        exit;
    }
    //
    //	If any replication is configured, connect
    //
    if ($sys_db_use_replication) {
        $gfconn2 = pg_pconnect(pg_connectstring($sys_dbreaddb, $sys_dbuser, $sys_dbpasswd, $sys_dbreadhost, $sys_dbreadport));
    } else {
        $gfconn2 = $gfconn;
    }
    //
    //	Now map the physical database connections to the
    //	"virtual" list that is used to distribute load in db_query()
    //
    define('SYS_DB_PRIMARY', $gfconn);
    define('SYS_DB_STATS', $gfconn2);
    define('SYS_DB_TROVE', $gfconn2);
    define('SYS_DB_SEARCH', $gfconn2);
    // Register top-level "finally" handler to abort current
    // transaction in case of error
    register_shutdown_function("system_cleanup");
}
开发者ID:neymanna,项目名称:fusionforge,代码行数:38,代码来源:database-pgsql.php


示例9: connect

 public function connect()
 {
     // Already connected
     if (is_resource($this->connection)) {
         return;
     }
     extract($this->config['connection']);
     $str = (isset($socket) and $socket) ? '' : (isset($host) ? "host='{$host}'" : '');
     $str .= isset($port) ? " port='{$port}'" : '';
     $str .= isset($user) ? " user='{$user}'" : '';
     $str .= isset($pass) ? " password='{$pass}'" : '';
     $str .= isset($database) ? " dbname='{$database}'" : '';
     // Connect to the database
     $this->connection = $this->config['persistent'] === TRUE ? pg_pconnect($str, PGSQL_CONNECT_FORCE_NEW) : pg_connect($str, PGSQL_CONNECT_FORCE_NEW);
     // A descriptive E_WARNING should have been thrown upon error
     // Test the return value as a last resort
     if (!is_resource($this->connection)) {
         throw new Database_Exception('Unable to connect to database');
     }
     if (isset($this->config['character_set'])) {
         // Set the character set
         $this->set_charset($this->config['character_set']);
     }
     if (empty($this->config['schema'])) {
         // Assume the default schema without changing the search path
         $this->config['schema'] = 'public';
     } else {
         $this->schema($this->config['schema']);
     }
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:30,代码来源:Database_Postgresql.php


示例10: sql_connect

 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
 {
     $this->connect_string = '';
     if ($sqluser) {
         $this->connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $this->connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         if (strpos($sqlserver, ':') !== false) {
             list($sqlserver, $sqlport) = explode(':', $sqlserver);
             $this->connect_string .= "host={$sqlserver} port={$sqlport} ";
         } else {
             if ($sqlserver != "localhost") {
                 $this->connect_string .= "host={$sqlserver} ";
             }
             if ($port) {
                 $this->connect_string .= "port={$port} ";
             }
         }
     }
     if ($database) {
         $this->dbname = $database;
         $this->connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     $this->db_connect_id = $this->persistency ? @pg_pconnect($this->connect_string) : @pg_connect($this->connect_string);
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
开发者ID:yunsite,项目名称:gloryroad,代码行数:33,代码来源:postgres.php


示例11: conectar

 public function conectar()
 {
     if (!parent::$enlace) {
         parent::$enlace = pg_pconnect('host=' . FS_HOST . ' dbname=' . FS_DB_NAME . ' port=' . FS_DB_PORT . ' user=' . FS_USERDB . ' password=' . FS_PASSDB);
     }
     return parent::$enlace;
 }
开发者ID:BGCX067,项目名称:facturascripts-svn-to-git,代码行数:7,代码来源:postgresql.php


示例12: connect

 public function connect()
 {
     if ($this->_connection) {
         return;
     }
     try {
         $this->_connection = empty($this->_config['connection']['persistent']) ? pg_connect($this->_config['connection']['info'], PGSQL_CONNECT_FORCE_NEW) : pg_pconnect($this->_config['connection']['info'], PGSQL_CONNECT_FORCE_NEW);
     } catch (ErrorException $e) {
         throw new Database_Exception(':error', array(':error' => $e->getMessage()));
     }
     if (!is_resource($this->_connection)) {
         throw new Database_Exception('Unable to connect to PostgreSQL ":name"', array(':name' => $this->_instance));
     }
     $this->_version = pg_parameter_status($this->_connection, 'server_version');
     if (!empty($this->_config['charset'])) {
         $this->set_charset($this->_config['charset']);
     }
     if (empty($this->_config['schema'])) {
         // Assume the default schema without changing the search path
         $this->_config['schema'] = 'public';
     } else {
         if (!pg_send_query($this->_connection, 'SET search_path = ' . $this->_config['schema'] . ', pg_catalog')) {
             throw new Database_Exception(pg_last_error($this->_connection));
         }
         if (!($result = pg_get_result($this->_connection))) {
             throw new Database_Exception(pg_last_error($this->_connection));
         }
         if (pg_result_status($result) !== PGSQL_COMMAND_OK) {
             throw new Database_Exception(pg_result_error($result));
         }
     }
 }
开发者ID:alekseyshavrak,项目名称:3cx,代码行数:32,代码来源:PostgreSQL.php


示例13: DBLayer

 function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
 {
     $this->prefix = $db_prefix;
     if ($db_host) {
         if (strpos($db_host, ':') !== false) {
             list($db_host, $dbport) = explode(':', $db_host);
             $connect_str[] = 'host=' . $db_host . ' port=' . $dbport;
         } else {
             $connect_str[] = 'host=' . $db_host;
         }
     }
     if ($db_name) {
         $connect_str[] = 'dbname=' . $db_name;
     }
     if ($db_username) {
         $connect_str[] = 'user=' . $db_username;
     }
     if ($db_password) {
         $connect_str[] = 'password=' . $db_password;
     }
     if ($p_connect) {
         $this->link_id = @pg_pconnect(implode(' ', $connect_str));
     } else {
         $this->link_id = @pg_connect(implode(' ', $connect_str));
     }
     if (!$this->link_id) {
         error('Unable to connect to PostgreSQL server.', __FILE__, __LINE__);
     }
     // Setup the client-server character set (UTF-8)
     if (!defined('FORUM_NO_SET_NAMES')) {
         $this->set_names('utf8');
     }
     return $this->link_id;
 }
开发者ID:mdb-webdev,项目名称:punbb,代码行数:34,代码来源:pgsql.php


示例14: OA_Dal_Delivery_connect

/**
 * The function to open a database connection, or return the resource if already open
 *
 * @param string $database   The name of the database config to use
 *                           (Must match the database section name in the conf file)
 * @return resource|false    The PgSQL database resource
 *                           or false on failure
 */
function OA_Dal_Delivery_connect($database = 'database')
{
    // If a connection already exists, then return that
    if ($database == 'database' && isset($GLOBALS['_MAX']['ADMIN_DB_LINK']) && is_resource($GLOBALS['_MAX']['ADMIN_DB_LINK'])) {
        return $GLOBALS['_MAX']['ADMIN_DB_LINK'];
    } elseif ($database == 'rawDatabase' && isset($GLOBALS['_MAX']['RAW_DB_LINK']) && is_resource($GLOBALS['_MAX']['RAW_DB_LINK'])) {
        return $GLOBALS['_MAX']['RAW_DB_LINK'];
    }
    // No connection exists, so create one
    $conf = $GLOBALS['_MAX']['CONF'];
    if (!empty($conf[$database])) {
        $dbConf = $conf[$database];
    } else {
        $dbConf = $conf['database'];
    }
    $dbParams = array();
    $dbParams[] = 'port=' . (isset($dbConf['port']) ? $dbConf['port'] : 5432);
    $dbParams[] = !empty($dbConf['protocol']) && $dbConf['protocol'] == 'unix' ? '' : 'host=' . $dbConf['host'];
    $dbParams[] = empty($dbConf['username']) ? '' : 'user=' . $dbConf['username'];
    $dbParams[] = empty($dbConf['password']) ? '' : 'password=' . $dbConf['password'];
    $dbParams[] = 'dbname=' . $dbConf['name'];
    if ($dbConf['persistent']) {
        $dbLink = @pg_pconnect(join(' ', $dbParams));
    } else {
        $dbLink = @pg_connect(join(' ', $dbParams));
    }
    if ($dbLink && !empty($conf['databasePgsql']['schema'])) {
        @pg_query($dbLink, "SET search_path='{$conf['databasePgsql']['schema']}'");
    }
    if ($dbLink && !empty($conf['databaseCharset']['checkComplete']) && !empty($conf['databaseCharset']['clientCharset'])) {
        @pg_client_encoding($dbLink, $conf['databaseCharset']['clientCharset']);
    }
    return $dbLink;
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:42,代码来源:pgsql.php


示例15: sql_db

 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->connect_string = "";
     if ($sqluser) {
         $this->connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $this->connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         if (ereg(":", $sqlserver)) {
             list($sqlserver, $sqlport) = split(":", $sqlserver);
             $this->connect_string .= "host={$sqlserver} port={$sqlport} ";
         } else {
             if ($sqlserver != "localhost") {
                 $this->connect_string .= "host={$sqlserver} ";
             }
         }
     }
     if ($database) {
         $this->dbname = $database;
         $this->connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     $this->db_connect_id = $this->persistency ? pg_pconnect($this->connect_string) : pg_connect($this->connect_string);
     return $this->db_connect_id ? $this->db_connect_id : false;
 }
开发者ID:rotvulpix,项目名称:php-nuke,代码行数:27,代码来源:postgres7.php


示例16: sql_db

 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->connect_string = "";
     if ($sqluser) {
         $this->connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $this->connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         if (ereg(":", $sqlserver)) {
             list($sqlserver, $sqlport) = split(":", $sqlserver);
             $this->connect_string .= "host={$sqlserver} port={$sqlport} ";
         } else {
             if ($sqlserver != "localhost") {
                 $this->connect_string .= "host={$sqlserver} ";
             }
         }
     }
     if ($database) {
         $this->dbname = $database;
         $this->connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     $this->db_connect_id = $this->persistency ? pg_pconnect($this->connect_string) : pg_connect($this->connect_string);
     $this->server = $sqlserver;
     $this->prefix = isset($GLOBALS['config']['prefix']) ? $GLOBALS['config']['prefix'] : '';
     $this->root = WWW_PREFIX;
     $this->cache_path = $this->root . '/' . $this->cache_path;
     $this->cache_enabled = isset($GLOBALS['config']['disable_sql_cache']) ? false : true;
     return $this->db_connect_id ? $this->db_connect_id : false;
 }
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:32,代码来源:pgsql.php


示例17: Open

function Open($dbType, $connectType = "c", $connect, $username = "", $password = "", $dbName)
{
    switch ($dbType) {
        case "mssql":
            if ($connectType == "c") {
                $idCon = mssql_connect($connect, $username, $password);
            } else {
                $idCon = mssql_pconnect($connect, $username, $password);
            }
            mssql_select_db($dbName);
            break;
        case "mysql":
            if ($connectType == "c") {
                $idCon = @mysql_connect($connect, $username, $password);
            } else {
                $idCon = @mysql_pconnect($connect, $username, $password);
            }
            $idCon1 = mysql_select_db($dbName, $idCon);
            break;
        case "pg":
            if ($connectType == "c") {
                $idCon = pg_connect($connect . " user=" . $username . " password=" . $password . " dbname=" . $dbName);
            } else {
                $idCon = pg_pconnect($connect . " user=" . $username . " password=" . $password . " dbname=" . $dbName);
            }
            break;
        default:
            $idCon = 0;
            break;
    }
    return $idCon;
}
开发者ID:laiello,项目名称:ebpls,代码行数:32,代码来源:multidbconnection.php


示例18: DBLayer

 function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
 {
     $this->prefix = $db_prefix;
     if ($db_host != '') {
         if (strpos($db_host, ':') !== false) {
             list($db_host, $dbport) = explode(':', $db_host);
             $connect_str[] = 'host=' . $db_host . ' port=' . $dbport;
         } else {
             if ($db_host != 'localhost') {
                 $connect_str[] = 'host=' . $db_host;
             }
         }
     }
     if ($db_name) {
         $connect_str[] = 'dbname=' . $db_name;
     }
     if ($db_username != '') {
         $connect_str[] = 'user=' . $db_username;
     }
     if ($db_password != '') {
         $connect_str[] = 'password=' . $db_password;
     }
     if ($p_connect) {
         $this->link_id = @pg_pconnect(implode(' ', $connect_str));
     } else {
         $this->link_id = @pg_connect(implode(' ', $connect_str));
     }
     if (!$this->link_id) {
         error('Unable to connect to PostgreSQL server', __FILE__, __LINE__);
     } else {
         return $this->link_id;
     }
 }
开发者ID:patrickod,项目名称:City-Blogger,代码行数:33,代码来源:pgsql.php


示例19: connect

 /**
  * Creates connection to database.
  * @param array $config Configuration options
  * @throws DriverException
  */
 public function connect(array $config)
 {
     $defaults = array('resource' => null, 'persistent' => false, 'charset' => 'utf8');
     $config += $defaults;
     if (isset($config['string'])) {
         $string = $config['string'];
     } else {
         // String generation
         $string = '';
         foreach (array('host', 'hostaddr', 'port', 'dbname', 'user', 'password', 'connect_timeout', 'options', 'sslmode', 'service') as $cfg) {
             if (isset($config[$cfg])) {
                 $string .= "{$cfg}={$config[$cfg]} ";
             }
         }
     }
     // Connect
     if (is_resource($config['resource'])) {
         $connection = $config['resource'];
     } elseif ($config['persistent']) {
         $connection = @pg_pconnect($string, PGSQL_CONNECT_FORCE_NEW);
     } else {
         $connection = @pg_connect($string, PGSQL_CONNECT_FORCE_NEW);
     }
     if (!is_resource($connection)) {
         throw new DriverException("Connection to database failed.");
     }
     $this->resource = $connection;
     // Encoding
     @pg_set_client_encoding($this->resource, $config['charset']);
     // Schema
     if (isset($config['schema'])) {
         $this->runQuery('SET search_path TO "' . $config['schema'] . '"');
     }
 }
开发者ID:smasty,项目名称:neevo,代码行数:39,代码来源:pgsql.php


示例20: sql_connect

 /**
  * {@inheritDoc}
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $connect_string = '';
     if ($sqluser) {
         $connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         // $sqlserver can carry a port separated by : for compatibility reasons
         // If $sqlserver has more than one : it's probably an IPv6 address.
         // In this case we only allow passing a port via the $port variable.
         if (substr_count($sqlserver, ':') === 1) {
             list($sqlserver, $port) = explode(':', $sqlserver);
         }
         if ($sqlserver !== 'localhost') {
             $connect_string .= "host={$sqlserver} ";
         }
         if ($port) {
             $connect_string .= "port={$port} ";
         }
     }
     $schema = '';
     if ($database) {
         $this->dbname = $database;
         if (strpos($database, '.') !== false) {
             list($database, $schema) = explode('.', $database);
         }
         $connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     if ($this->persistency) {
         if (!function_exists('pg_pconnect')) {
             $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?';
             return $this->sql_error('');
         }
         $collector = new \phpbb\error_collector();
         $collector->install();
         $this->db_connect_id = !$new_link ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW);
     } else {
         if (!function_exists('pg_connect')) {
             $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?';
             return $this->sql_error('');
         }
         $collector = new \phpbb\error_collector();
         $collector->install();
         $this->db_connect_id = !$new_link ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW);
     }
     $collector->uninstall();
     if ($this->db_connect_id) {
         if ($schema !== '') {
             @pg_query($this->db_connect_id, 'SET search_path TO ' . $schema);
         }
         return $this->db_connect_id;
     }
     $this->connect_error = $collector->format_errors();
     return $this->sql_error('');
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:62,代码来源:postgres.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pg_ping函数代码示例发布时间:2022-05-15
下一篇:
PHP pg_parameter_status函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap