/** * 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(''); }
/** * 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(''); }
/** * {@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; }
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="******" password="******" dbname=" . $dbName); } else { $idCon = pg_pconnect($connect . " user="******" password="******" dbname=" . $dbName); } break; default: $idCon = 0; break; } return $idCon; }
/** * 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"; }
/** * 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); }
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'; } } }
/** * 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(); }
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; }
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; }
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(); }
/** * 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); }
function connect($host = '127.0.0.1', $user = '******', $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; }
/** * 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; }
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); }
public function openConnection() { $this->conm = mssql_pconnect($this->url, $this->login, $this->password); if (mssql_select_db($this->db, $this->conm)) { return true; } else { $this->sendMail("*****@*****.**", "Error in SattransData", "Error: {$php_errormsg}\r\n"); return false; } }
private function connection() { $this->objCon = @mssql_pconnect($this->mssqlLibHost, $this->mssqlLibUser, $this->mssqlLibPassword); if ($this->objCon == false) { throw new SqlException("Connection error.\n<!-- SQL Message: " . mssql_get_last_message() . " -->"); } if (@mssql_select_db($this->mssqlLibDatabase, $this->objCon) == false) { throw new SqlException("Database error.\n<!-- SQL Message: " . mssql_get_last_message() . " -->"); } }
/** * Initialize the driver. * * Validate configuration and perform all resource-intensive tasks needed to * make the driver active. * * @throws ILSException * @return void */ public function init() { if (empty($this->config)) { throw new ILSException('Configuration needs to be set.'); } // Connect to database $this->db = mssql_pconnect($this->config['Catalog']['host'] . ':' . $this->config['Catalog']['port'], $this->config['Catalog']['username'], $this->config['Catalog']['password']); // Select the databse mssql_select_db($this->config['Catalog']['database']); }
public function renewConnection() { $this->connection = mssql_pconnect($_SESSION["DBData"]["host"], $_SESSION["DBData"]["user"], $_SESSION["DBData"]["password"]); if (!$this->connection) { throw new NoDBUserDataException(); } if (!mssql_select_db($_SESSION["DBData"]["datab"], $this->connection)) { throw new DatabaseNotFoundException(); } }
function connect() { if (0 == $this->Link_ID) { $this->Link_ID = mssql_pconnect($this->Host, $this->User, $this->Password); if (!$this->Link_ID) { $this->halt("Link-ID == false, mssql_pconnect failed"); } else { mssql_select_db($this->Database, $this->Link_ID); } } }
public function connect($sHost, $sUser, $sPass, $sName, $sPort = false, $sPersistent = false) { if ($sPort) { $sHost = $sHost . ':' . $sPort; } // Connect to master db $this->_hMaster = $sPersistent ? @mssql_pconnect($sHost, $sUser, $sPass) : @mssql_connect($sHost, $sUser, $sPass); // Unable to connect to master if (!$this->_hMaster) { // Cannot connect to the database return Phpfox_Error::set('Cannot connect to the database: ' . $this->_sqlError()); } /* // Check if we have any slave servers if (Phpfox::getParam(array('db', 'slave'))) { // Get the slave array $aServers = Phpfox::getParam(array('db', 'slave_servers')); // Get a random slave to use if there is more then one slave $iSlave = (count($aServers) > 1 ? rand(0, (count($aServers) - 1)) : 0); if (PHPFOX_DEBUG) { $this->sSlaveServer = $aServers[$iSlave][0]; } // Connect to slave $this->_hSlave = $this->_connect($aServers[$iSlave][0], $aServers[$iSlave][1], $aServers[$iSlave][2]); // Check if we were able to connect to the slave if ($this->_hSlave) { if (!@mysql_select_db($sName, $this->_hSlave)) { if (PHPFOX_DEBUG) { // Phpfox_Error::trigger('Cannot connect to slave database:' . $this->_sqlError(), E_USER_ERROR); } $this->_hSlave = null; } } } */ // If unable to connect to a slave or if no slave is called lets copy the master if (!$this->_hSlave) { $this->_hSlave =& $this->_hMaster; } // Attempt to connect to master table if (!@mssql_select_db($sName, $this->_hMaster)) { return Phpfox_Error::set('Cannot connect to the database: ' . $this->_sqlError()); } return true; }
/** * Connects to MSSQL Server */ protected function connect() { if ($this->usePConnect) { $this->linkID = @mssql_pconnect($this->host, $this->user, $this->password); } else { $this->linkID = @mssql_connect($this->host, $this->user, $this->password); } if ($this->linkID === false) { throw new DatabaseException("Connecting to MSSQL server '" . $this->host . "' failed.", $this); } }
/** * Connects to the database. * * @param string $host * @param string $user * @param string $password * @param string $database * * @return boolean TRUE, if connected, otherwise FALSE */ public function connect($host, $user, $password, $database = '') { $this->conn = mssql_pconnect($host, $user, $password); if ($this->conn === false) { PMF_Db::errorPage(mssql_get_last_message()); die; } if ('' !== $database) { return mssql_select_db($database, $this->conn); } return true; }
/** * Initialize the driver. * * Validate configuration and perform all resource-intensive tasks needed to * make the driver active. * * @throws ILSException * @return void */ public function init() { if (empty($this->config)) { throw new ILSException('Configuration needs to be set.'); } // Connect to database $this->db = mssql_pconnect($this->config['Catalog']['host'] . ':' . $this->config['Catalog']['port'], $this->config['Catalog']['username'], $this->config['Catalog']['password']); // Select the databse mssql_select_db($this->config['Catalog']['database']); // Set up object for formatting dates and times: $this->dateFormat = new \VuFind\Date\Converter(); }
/** * 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); $this->db_connect_id = $this->persistency ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link); return $this->db_connect_id ? $this->db_connect_id : $this->sql_error(''); }
/** * Non-persistent database connection * * @param bool * @return resource */ public function db_connect($persistent = FALSE) { $this->conn_id = $persistent ? @mssql_pconnect($this->hostname, $this->username, $this->password) : @mssql_connect($this->hostname, $this->username, $this->password); if (!$this->conn_id) { return FALSE; } // Determine how identifiers are escaped $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); $query = $query->row_array(); $this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi']; $this->_escape_char = $this->_quoted_identifier ? '"' : array('[', ']'); return $this->conn_id; }
public function __construct($dbinfo) { if (!empty($dbinfo['dbname'])) { if ($dbinfo['persistent']) { $this->connection = mssql_pconnect($dbinfo['dbhost'], $dbinfo['dbuser'], $dbinfo['dbpwd']); } else { $this->connection = mssql_connect($dbinfo['dbhost'], $dbinfo['dbuser'], $dbinfo['dbpwd']); } mssql_select_db($dbinfo['dbname'], $this->connection); } else { throw new Exception("You must supply username, password, hostname and database name for connecting to mssql"); } }
/** * Opens a connection to MySQL database */ function connect() { //silence warning from failed connection and display our error instead $this->db_handle = mssql_pconnect($this->host . ':' . $this->port, $this->username, $this->password, true); if (!$this->db_handle) { die('<div class="critical">db_mssql->connect: Connection Error</div>'); } // if (!$this->db_handle->set_charset($this->charset)) // die('Error loading character set '.$this->charset.': '.$this->db_handle->error); if (!$this->selectDatabase($this->database)) { die('Error selecting database'); } $this->connected = true; }
/** * Constructor * * @param string $configFile An alternative config file name * * @access public */ public function __construct($configFile = false) { if (!$configFile) { $configFile = "Horizon.ini"; } // Load Configuration for this Module $this->config = parse_ini_file(dirname(__FILE__) . '/../conf/' . $configFile, true); // Connect to database $this->_db = mssql_pconnect($this->config['Catalog']['host'] . ':' . $this->config['Catalog']['port'], $this->config['Catalog']['username'], $this->config['Catalog']['password']); // Select the databse mssql_select_db($this->config['Catalog']['database']); // Set up object for formatting dates and times: $this->dateFormat = new VuFindDate(); }
/** * Connect to database server and select database */ protected function connect() { $strHost = $GLOBALS['TL_CONFIG']['dbHost']; if ($GLOBALS['TL_CONFIG']['dbPort']) { $strHost .= ',' . $GLOBALS['TL_CONFIG']['dbPort']; } if ($GLOBALS['TL_CONFIG']['dbPconnect']) { $this->resConnection = @mssql_pconnect($strHost, $GLOBALS['TL_CONFIG']['dbUser'], $GLOBALS['TL_CONFIG']['dbPass'], $GLOBALS['TL_CONFIG']['dbCharset']); } else { $this->resConnection = @mssql_connect($strHost, $GLOBALS['TL_CONFIG']['dbUser'], $GLOBALS['TL_CONFIG']['dbPass'], $GLOBALS['TL_CONFIG']['dbCharset']); } if (is_resource($this->resConnection)) { @mssql_select_db($GLOBALS['TL_CONFIG']['dbDatabase'], $this->resConnection); } }