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


PHP mysql_pconnect函数代码示例

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


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

示例1: F2MysqlClass

 function F2MysqlClass($DBHost, $DBUser, $DBPswd, $DBName, $DBNewlink = "false", $debug = false)
 {
     if ($DBNewlink == "true") {
         if (!mysql_pconnect($DBHost, $DBUser, $DBPswd)) {
             $this->halt("Don't connect to database!");
         }
     } else {
         if (!mysql_connect($DBHost, $DBUser, $DBPswd)) {
             $this->halt("Don't connect to database!");
         }
     }
     if ($this->getServerInfo() > '4.1') {
         mysql_query("SET NAMES 'utf8'");
     }
     if ($this->getServerInfo() > '5.0.1') {
         mysql_query("SET sql_mode=''");
     }
     if ($DBName) {
         $this->selectDB($DBName);
     }
     if ($debug) {
         $this->_debug = $debug;
         $this->_fp = fopen(F2BLOG_ROOT . "./cache/" . date("Ymd") . ".log", "a");
     }
 }
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:25,代码来源:db.php

示例2: db_pconnect

 /**
  * Persistent database connection
  *
  * @access	private called by the base class
  * @return	resource
  */
 private function db_pconnect()
 {
     if ($this->port != '') {
         $this->db_hostname .= ':' . $this->port;
     }
     return @mysql_pconnect($this->db_hostname, $this->db_username, $this->db_password);
 }
开发者ID:puncoz,项目名称:pankajnepal.com.np,代码行数:13,代码来源:database.php

示例3: connect

 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         if ($this->pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) {
             throw_exception(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
开发者ID:omusico,项目名称:AndyCMS,代码行数:43,代码来源:DbMysql.class.php

示例4: 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

示例5: sql_db

 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->password = $sqlpassword;
     $this->server = $sqlserver;
     $this->dbname = $database;
     if ($this->persistency) {
         $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
     } else {
         $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
     }
     if ($this->db_connect_id) {
         if ($database != "") {
             $this->dbname = $database;
             $dbselect = @mysql_select_db($this->dbname);
             if (!$dbselect) {
                 @mysql_close($this->db_connect_id);
                 $this->db_connect_id = $dbselect;
             }
         }
         return $this->db_connect_id;
     } else {
         return false;
     }
 }
开发者ID:ZerGabriel,项目名称:adr-rpg,代码行数:26,代码来源:mysql.php

示例6: getID3_cached_mysql

 function getID3_cached_mysql($host, $database, $username, $password)
 {
     // Check for mysql support
     if (!function_exists('mysql_pconnect')) {
         throw new Exception('PHP not compiled with mysql support.');
     }
     // Connect to database
     $this->connection = mysql_pconnect($host, $username, $password);
     if (!$this->connection) {
         throw new Exception('mysql_pconnect() failed - check permissions and spelling.');
     }
     // Select database
     if (!mysql_select_db($database, $this->connection)) {
         throw new Exception('Cannot use database ' . $database);
     }
     // Create cache table if not exists
     $this->create_table();
     // Check version number and clear cache if changed
     $version = '';
     if ($this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename` = '" . mysql_real_escape_string(GETID3_VERSION) . "') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
         list($version) = mysql_fetch_array($this->cursor);
     }
     if ($version != GETID3_VERSION) {
         $this->clear_cache();
     }
     parent::getID3();
 }
开发者ID:sahartak,项目名称:newsroyal,代码行数:27,代码来源:extension.cache.mysql.php

示例7: connect

 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect()
 {
     if (!$this->connected) {
         $config = $this->config;
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         if ($this->pconnect) {
             $this->linkID = mysql_pconnect($host, $config['username'], $config['password']);
         } else {
             $this->linkID = mysql_connect($host, $config['username'], $config['password'], true);
         }
         if (!$this->linkID || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID)) {
             echo mysql_error();
         }
         $dbVersion = mysql_get_server_info($this->linkID);
         if ($dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES 'UTF8'", $this->linkID);
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->linkID);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         unset($this->config);
     }
 }
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:38,代码来源:SimpleDB.class.php

示例8: __construct

 public function __construct($host, $database, $username, $password, $table = 'getid3_cache')
 {
     // Check for mysql support
     if (!function_exists('mysql_pconnect')) {
         throw new Exception('PHP not compiled with mysql support.');
     }
     // Connect to database
     $this->connection = mysql_pconnect($host, $username, $password);
     if (!$this->connection) {
         throw new Exception('mysql_pconnect() failed - check permissions and spelling.');
     }
     // Select database
     if (!mysql_select_db($database, $this->connection)) {
         throw new Exception('Cannot use database ' . $database);
     }
     // Set table
     $this->table = $table;
     // Create cache table if not exists
     $this->create_table();
     // Check version number and clear cache if changed
     $version = '';
     $SQLquery = 'SELECT `value`';
     $SQLquery .= ' FROM `' . mysql_real_escape_string($this->table) . '`';
     $SQLquery .= ' WHERE (`filename` = \'' . mysql_real_escape_string(getID3::VERSION) . '\')';
     $SQLquery .= ' AND (`filesize` = -1)';
     $SQLquery .= ' AND (`filetime` = -1)';
     $SQLquery .= ' AND (`analyzetime` = -1)';
     if ($this->cursor = mysql_query($SQLquery, $this->connection)) {
         list($version) = mysql_fetch_array($this->cursor);
     }
     if ($version != getID3::VERSION) {
         $this->clear_cache();
     }
     parent::__construct();
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:35,代码来源:extension.cache.mysql.php

示例9: connect

 function connect()
 {
     global $usepconnect;
     // connect to db server
     if (0 == $this->link_id) {
         if ($this->password == "") {
             if ($usepconnect == 1) {
                 $this->link_id = mysql_pconnect($this->server, $this->user);
             } else {
                 $this->link_id = mysql_connect($this->server, $this->user);
             }
         } else {
             if ($usepconnect == 1) {
                 $this->link_id = mysql_pconnect($this->server, $this->user, $this->password);
             } else {
                 $this->link_id = mysql_connect($this->server, $this->user, $this->password);
             }
         }
         if (!$this->link_id) {
             $this->halt("Link-ID == false, connect failed");
         }
         if ($this->database != "") {
             if (!mysql_select_db($this->database, $this->link_id)) {
                 $this->halt("cannot use database " . $this->database);
             }
         }
     }
 }
开发者ID:nldfr219,项目名称:zhi,代码行数:28,代码来源:db_mysql.php

示例10: PMA_DBI_connect

function PMA_DBI_connect($user, $password)
{
    global $cfg, $php_errormsg;
    $server_port = empty($cfg['Server']['port']) ? '' : ':' . $cfg['Server']['port'];
    if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
        $cfg['Server']['socket'] = '';
    }
    $server_socket = empty($cfg['Server']['socket']) ? '' : ':' . $cfg['Server']['socket'];
    if (PMA_PHP_INT_VERSION >= 40300 && PMA_MYSQL_CLIENT_API >= 32349) {
        $client_flags = $cfg['Server']['compress'] && defined('MYSQL_CLIENT_COMPRESS') ? MYSQL_CLIENT_COMPRESS : 0;
        // always use CLIENT_LOCAL_FILES as defined in mysql_com.h
        // for the case where the client library was not compiled
        // with --enable-local-infile
        $client_flags |= 128;
    }
    if (empty($client_flags)) {
        $connect_func = 'mysql_' . ($cfg['PersistentConnections'] ? 'p' : '') . 'connect';
        $link = @$connect_func($cfg['Server']['host'] . $server_port . $server_socket, $user, $password);
    } else {
        if ($cfg['PersistentConnections']) {
            $link = @mysql_pconnect($cfg['Server']['host'] . $server_port . $server_socket, $user, $password, $client_flags);
        } else {
            $link = @mysql_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, $password, FALSE, $client_flags);
        }
    }
    if (empty($link)) {
        PMA_auth_fails();
    }
    // end if
    PMA_DBI_postConnect($link);
    return $link;
}
开发者ID:dapfru,项目名称:gladiators,代码行数:32,代码来源:mysql.dbi.lib.php

示例11: connect

 public function connect()
 {
     /**
     		if ($this->conn == "pconn") {
     			//永久链接
     			$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
     		} else {
     			//即时链接
     			$this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
     		}
     
     		if (!mysql_select_db($this->db_database, $this->conn)) {
     			if ($this->show_error) {
     				$this->show_error("数据库不可用:", $this->db_database);
     			}
     		}
     		mysql_query("SET NAMES $this->coding");
     		**/
     if ($this->conn == "pconn") {
         //永久链接
         $this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
     } else {
         //即时链接
         $this->conn = mysqli_connect($this->db_host, $this->db_user, $this->db_pwd, $this->db_database);
     }
     if (mysqli_connect_errno($this->conn)) {
         $this->show_error("数据库不可用:", $this->db_database);
     }
     mysqli_query($this->conn, "SET NAMES {$this->coding}");
 }
开发者ID:iloster,项目名称:tinyphp,代码行数:30,代码来源:lib_mysql.php

示例12: connect

 function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset, $pconnect = 0, $tablepre = '', $time = 0)
 {
     $this->tablepre = $tablepre;
     if ($pconnect) {
         if (!($this->link = mysql_pconnect($dbhost, $dbuser, $dbpw))) {
             die('Can not connect to MySQL server');
         }
     } else {
         if (!($this->link = mysql_connect($dbhost, $dbuser, $dbpw, 1))) {
             die('Can not connect to MySQL server');
         }
     }
     if ($this->version() > '4.1') {
         if ($dbcharset) {
             mysql_query("SET character_set_connection=" . $dbcharset . ", character_set_results=" . $dbcharset . ", character_set_client=binary", $this->link);
         }
         if ($this->version() > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->link);
         }
     }
     if ($dbname) {
         $db_selected = mysql_select_db($dbname, $this->link);
         if (!$db_selected) {
             $sql = "CREATE DATABASE {$dbname} DEFAULT CHARACTER SET utf8;";
             self::query($sql);
             mysql_select_db($dbname, $this->link);
         }
     }
 }
开发者ID:962464,项目名称:wstmall,代码行数:29,代码来源:install_mysql.php

示例13: connect

 function connect($db, $return = false)
 {
     if ($db['port']) {
         $db['server'] .= ':' . $db['port'];
     }
     if ($this->link_identifier) {
         $this->disconnect();
     }
     $this->link_identifier = $db['persistent'] ? @mysql_pconnect($db['server'], $db['username'], $db['password']) : @mysql_connect($db['server'], $db['username'], $db['password']);
     if ($this->link_identifier) {
         if (@mysql_select_db($db['database'])) {
             mysql_query('SET NAMES utf8', $this->link_identifier);
             //mysql_query('SET character_set_results = NULL', $this->link_identifier);
             return $this->link_identifier;
         }
         $error = '<center>There is currently a problem with the site<br/>Please try again later<br /><br />Error Code: DB2</center>';
     }
     if (!$this->report_error) {
         return false;
     }
     if (!isset($error)) {
         $error = '<center>There is currently a problem with the site<br/>Please try again later<br /><br />Error Code: DB1</center>';
     }
     $this->disconnect();
     trigger_error($error, E_USER_ERROR);
 }
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:26,代码来源:mysql.php

示例14: __construct

 public function __construct()
 {
     // attempt to connect
     if (!($this->db = !$_SERVER['tracker']['db_persist'] ? mysql_connect($_SERVER['tracker']['db_host'], $_SERVER['tracker']['db_user'], $_SERVER['tracker']['db_pass']) : mysql_pconnect($_SERVER['tracker']['db_host'], $_SERVER['tracker']['db_user'], $_SERVER['tracker']['db_pass'])) or !mysql_select_db($_SERVER['tracker']['db_name'], $this->db)) {
         tracker_error(mysql_errno($this->db) . ' - ' . mysql_error($this->db));
     }
 }
开发者ID:istrwei,项目名称:peertracker,代码行数:7,代码来源:tracker.mysql.php

示例15: connect

 function connect()
 {
     if ($this->pconnect) {
         if (!($this->dou_link = @mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpass))) {
             $this->error('Can not pconnect to mysql server');
             return false;
         }
     } else {
         if (!($this->dou_link = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpass, true))) {
             $this->error('Can not connect to mysql server');
             return false;
         }
     }
     if ($this->version() > '4.1') {
         if ($this->charset) {
             $this->query("SET character_set_connection=" . $this->charset . ", character_set_results=" . $this->charset . ", character_set_client=binary");
         }
         if ($this->version() > '5.0.1') {
             $this->query("SET sql_mode=''");
         }
     }
     if (mysql_select_db($this->dbname, $this->dou_link) === false) {
         $this->error("NO THIS DBNAME:" . $this->dbname);
         return false;
     }
 }
开发者ID:zackCzy,项目名称:nailao,代码行数:26,代码来源:mysql.class.php


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