本文整理汇总了PHP中mssql_pconnect函数的典型用法代码示例。如果您正苦于以下问题:PHP mssql_pconnect函数的具体用法?PHP mssql_pconnect怎么用?PHP mssql_pconnect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mssql_pconnect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sql_connect
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
if (!function_exists('mssql_connect')) {
$this->connect_error = 'mssql_connect function does not exist, is mssql extension installed?';
return $this->sql_error('');
}
$this->persistency = $persistency;
$this->user = $sqluser;
$this->dbname = $database;
$port_delimiter = defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN' ? ',' : ':';
$this->server = $sqlserver . ($port ? $port_delimiter . $port : '');
@ini_set('mssql.charset', 'UTF-8');
@ini_set('mssql.textlimit', 2147483647);
@ini_set('mssql.textsize', 2147483647);
if (version_compare(PHP_VERSION, '5.1.0', '>=') || version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.1', '>=')) {
$this->db_connect_id = $this->persistency ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link);
} else {
$this->db_connect_id = $this->persistency ? @mssql_pconnect($this->server, $this->user, $sqlpassword) : @mssql_connect($this->server, $this->user, $sqlpassword);
}
if ($this->db_connect_id && $this->dbname != '') {
if (!@mssql_select_db($this->dbname, $this->db_connect_id)) {
@mssql_close($this->db_connect_id);
return false;
}
}
return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
}
示例2: sql_connect
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->server = $sqlserver . (($port) ? ':' . $port : '');
$this->dbname = $database;
@ini_set('mssql.charset', 'UTF-8');
@ini_set('mssql.textlimit', 2147483647);
@ini_set('mssql.textsize', 2147483647);
if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.1', '>=')))
{
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link);
}
else
{
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword) : @mssql_connect($this->server, $this->user, $sqlpassword);
}
if ($this->db_connect_id && $this->dbname != '')
{
if (!@mssql_select_db($this->dbname, $this->db_connect_id))
{
@mssql_close($this->db_connect_id);
return false;
}
}
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}
示例3: connect
/**
* {@inheritdoc}
*/
public function connect()
{
$config = $this->config;
$config = array_merge($this->baseConfig, $config);
$os = env('OS');
if (!empty($os) && strpos($os, 'Windows') !== false) {
$sep = ',';
} else {
$sep = ':';
}
$this->connected = false;
if (is_numeric($config['port'])) {
$port = $sep . $config['port'];
// Port number
} elseif ($config['port'] === null) {
$port = '';
// No port - SQL Server 2005
} else {
$port = '\\' . $config['port'];
// Named pipe
}
if (!$config['persistent']) {
$this->connection = mssql_connect($config['host'] . $port, $config['username'], $config['password'], true);
} else {
$this->connection = mssql_pconnect($config['host'] . $port, $config['username'], $config['password']);
}
if (mssql_select_db($config['database'], $this->connection)) {
$this->qery('SET DATEFORMAT ymd');
$this->connected = true;
}
return $this->connection;
}
示例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;
}
示例5: StartConnection
/**
* Start Connection Server
* Connect to Microsoft SQL Server
*
* @return void
*/
public function StartConnection()
{
if (!extension_loaded("mssql")) {
if (!extension_loaded("sqlsrv")) {
return $this->results['Connect'] = "NO_PHP_EXTENSION";
} else {
$this->useSqlsrv = TRUE;
}
}
if (!$this->settings['hostport']) {
$this->settings['hostport'] = 1433;
}
$new_link = count($this->connections) > 0;
$port = (strtoupper(substr(PHP_OS, 0, 3)) === "WIN" ? "," : ":") . $this->settings['hostport'];
if (!$this->useSqlsrv) {
if ($this->settings['persistent']) {
$this->connections[$this->id] = mssql_pconnect($this->settings['hostname'] . $port, $this->settings['username'], $this->settings['password'], $new_link);
} else {
$this->connections[$this->id] = mssql_connect($this->settings['hostname'] . $port, $this->settings['username'], $this->settings['password'], $new_link);
}
}
if (!$this->connections[$this->id]) {
return $this->results['Connect'] = "CONNECTION_FAILED";
}
if (!$this->SelectDataBase($this->settings['database'], $this->id)) {
return $this->results['Connect'] = "DATABASE_FAILED";
}
$this->id++;
$this->connected = TRUE;
$this->currentLink = $this->id - 1;
return $this->results['Connect'] = "CONNECTED";
}
示例6: db_pconnect
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
if ($this->port != '') {
$this->hostname .= ',' . $this->port;
}
return @mssql_pconnect($this->hostname, $this->username, $this->password);
}
示例7: reconnect
function reconnect()
{
global $gbl, $sgbl, $login, $ghtml;
$this->__readserver = 'localhost';
$user = $sgbl->__var_admin_user;
$db = $sgbl->__var_dbf;
$pass = getAdminDbPass();
$readserver = $this->__readserver;
$fdbvar = "__fdb_" . $this->__readserver;
log_log("database_reconnect", "Reconnecting again");
if ($sgbl->__var_database_type === 'mysql') {
$gbl->{$fdbvar} = mysql_connect($readserver, $user, $pass);
mysql_select_db($db);
self::$__database = 'mysql';
} else {
if ($sgbl->__var_database_type === 'mssql') {
//print("$user, $pass <br> \n");
//$gbl->$fdbvar = mssql_connect('\\.\pipe\MSSQL$LXLABS\sql\query');
$gbl->{$fdbvar} = mssql_pconnect("{$readserver},{$sgbl->__var_mssqlport}");
mssql_select_db($db);
self::$__database = 'mssql';
} else {
$gbl->{$fdbvar} = new PDO("sqlite:{$db}");
self::$__database = 'sqlite';
}
}
}
示例8: connect
/**
* Connect
*
* @param bool reconnect default FALSE
* @return bool success
* @throws rdbms.SQLConnectException
*/
public function connect($reconnect = false)
{
if (is_resource($this->handle)) {
return true;
}
// Already connected
if (!$reconnect && false === $this->handle) {
return false;
}
// Previously failed connecting
$this->_obs && $this->notifyObservers(new \rdbms\DBEvent(\rdbms\DBEvent::CONNECT, $reconnect));
if ($this->flags & DB_PERSISTENT) {
$this->handle = mssql_pconnect($this->dsn->getHost(), $this->dsn->getUser(), $this->dsn->getPassword());
} else {
$this->handle = mssql_connect($this->dsn->getHost(), $this->dsn->getUser(), $this->dsn->getPassword());
}
if (!is_resource($this->handle)) {
$e = new \rdbms\SQLConnectException(trim(mssql_get_last_message()), $this->dsn);
\xp::gc(__FILE__);
throw $e;
}
\xp::gc(__FILE__);
$this->_obs && $this->notifyObservers(new \rdbms\DBEvent(\rdbms\DBEvent::CONNECTED, $reconnect));
return parent::connect();
}
示例9: sql_db
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->server = $sqlserver;
$this->dbname = $database;
$this->db_connect_id = $this->persistency ? @mssql_pconnect($this->server, $this->user, $this->password) : @mssql_connect($this->server, $this->user, $this->password);
if ($this->db_connect_id && $this->dbname != "") {
if (!mssql_select_db($this->dbname, $this->db_connect_id)) {
mssql_close($this->db_connect_id);
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$this->sql_time += $endtime - $starttime;
return false;
}
}
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$this->sql_time += $endtime - $starttime;
return $this->db_connect_id;
}
示例10: connect
public function connect()
{
if ($this->conn_id && $this->state == self::OPEN) {
mssql_select_db($this->getDatabase(), $this->conn_id);
return true;
}
//TODO preConnect actions should be called from here
$hostString = $this->getHost();
if ($this->getPort() != '') {
$hostString .= ':' . $this->getPort();
}
if (isset($this->options['socket']) && $this->options['socket'] != '') {
$hostString .= ':' . $this->options['socket'];
}
$flags = isset($this->options['flags']) ? $this->options['flags'] : null;
if (isset($this->options['persistent']) && $this->options['persistent'] == true) {
$this->conn_id = @mssql_pconnect($hostString, $this->getUser(), $this->getPassword(), $flags);
} else {
$this->conn_id = @mssql_connect($hostString, $this->getUser(), $this->getPassword(), $flags);
}
if (!$this->conn_id) {
$this->state = self::CLOSED;
$msg = '[!Database connection error!]: ' . $this->getDatabase() . ' - ' . $this->getErrorMsg();
PhpBURN_Message::output($msg, PhpBURN_Message::ERROR);
return false;
}
//Selecting database
mssql_select_db($this->getDatabase(), $this->conn_id);
$this->state = self::OPEN;
//TODO onConnectSucess actions should be called from here
return true;
}
示例11: connect
public function connect()
{
$this->link = $this->_config['pconnect'] == 0 ? @mssql_connect($this->_config['host'], $this->_config['username'], $this->_config['password']) : @mssql_pconnect($this->_config['host'], $this->_config['username'], $this->_config['password']);
if (!$this->link) {
$this->halt("Connect to mssql failed");
}
$this->selectDb();
}
示例12: connect
/**
* Connects to the database.
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean TRUE, if connected, otherwise FALSE
*/
function connect($host, $user, $passwd, $db)
{
$this->conn = mssql_pconnect($host, $user, $passwd);
if (empty($db) or $this->conn == false) {
PMF_Db::errorPage(mssql_get_last_message());
die;
}
return mssql_select_db($db, $this->conn);
}
示例13: connect
function connect($host = '127.0.0.1', $user = 'sa', $passwd = 'sa')
{
$this->con = mssql_pconnect($host, $user, $passwd);
if (!$this->con) {
$this->debug('Connect To Host : ' . $host . ' Faild!');
}
$this->query('SET TEXTSIZE 2147483647');
return $this->con;
}
示例14: connect
/**
* Connect to the database.
* @param str[] config
*/
function connect($config)
{
$connString = sprintf('host=%s dbname=%s user=%s password=%s', $config['server'], $config['database'], $config['username'], $config['password']);
if ($this->db = mssql_pconnect($config['server'], $config['username'], $config['password'])) {
mssql_select_db($config['database']);
return TRUE;
}
return FALSE;
}
示例15: connect
public function connect($config = array())
{
$this->config = $config;
$server = !empty($this->config['server']) ? $this->config['server'] : $this->config['host'];
$this->connect = $this->config['pconnect'] === true ? @mssql_pconnect($server, $this->config['user'], $this->config['password']) : @mssql_connect($server, $this->config['user'], $this->config['password']);
if (empty($this->connect)) {
die(getErrorMessage('Database', 'mysqlConnectError'));
}
mssql_select_db($this->config['database'], $this->connect);
}