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


PHP mssql_connect函数代码示例

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


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

示例1: 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;
 }
开发者ID:BackupTheBerlios,项目名称:phpbbsfp,代码行数:30,代码来源:mssql.php

示例2: dbOpen_MSSQL

/**
 * Abra a conexão com o banco de dados MSSQL
 *
 * <code>
 * $mssqlHandle = dbOpen_MSSQL("MSSQL", "database", "user", "password");
 * </code>
 *
 * @param string $dbHost string de conexão com o banco de dados
 * @param string $dbDatabase[optional] string database utilizado
 * @param string $dbUser[optional] nome do usuário
 * @param string $dbPassword[optional] senha do usuário
 *
 * @return array com o handleId e o nome do driver
 *
 * @since Versão 1.0
 */
function dbOpen_MSSQL(&$dbHandle)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbDriver = $dbHandle[dbHandleDriver];
    if (!function_exists("mssql_connect")) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}() - Connect</b>:" . "<br />extension=<b>php_mssql.dll</b> is not loaded";
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    $dbHost = $dbHandle[dbHandleHost];
    $dbDatabase = $dbHandle[dbHandleDatabase];
    $dbUser = $dbHandle[dbHandleUser];
    $dbPassword = $dbHandle[dbHandlePassword];
    // @TODO Incluir tratamento para ver se o driver está carregado
    if (!($mssqlConn = @mssql_connect($dbHost, $dbUser, $dbPassword))) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}() - Connect</b>:" . "<br /><b>Connection</b>: " . $dbHost . "<br /><b>Database</b>: " . $dbDatabase . "<br /><b>Message</b>: [" . mssql_get_last_message() . "]";
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    if (!@mssql_select_db($dbDatabase, $mssqlConn)) {
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}() - SelectDB</b>:" . "<br /><b>Connection</b>: " . $dbHost . "<br /><b>Database</b>: " . $dbDatabase . "<br /><b>Message</b>: [" . mssql_get_last_message() . "]";
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $mssqlConn;
}
开发者ID:BGCX262,项目名称:ztag-svn-to-git,代码行数:47,代码来源:dbMSSQL.inc.php

示例3: 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();
 }
开发者ID:xp-framework,项目名称:rdbms,代码行数:32,代码来源:MsSQLConnection.class.php

示例4: 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";
 }
开发者ID:ADMTec,项目名称:effectweb-project,代码行数:38,代码来源:mssqlClient.lib.php

示例5: __construct

 public function __construct($hostname, $userid, $password)
 {
     $this->hostname = $hostname;
     $this->userid = $userid;
     $this->password = $password;
     $this->connection = mssql_connect($hostname, $userid, $password, false);
 }
开发者ID:sigmadesarrollo,项目名称:logisoft,代码行数:7,代码来源:MSSQLInspector.php

示例6: conn

function conn($DB)
{
    $serverName = "intelisis";
    //serverName\instanceName
    $connectionInfo = array("Database" => $DB, "UID" => "intelisis", "PWD" => "");
    $conn = mssql_connect($serverName, "intelisis", "");
    mssql_select_db($DB, $conn);
    $user = $_SESSION["user"];
    if (!$conn) {
        die('Something went wrong while connecting to MSSQL');
    }
    $con1 = "set dateformat dmy";
    $con1 = mssql_query($con1);
    $con2 = "SET DATEFIRST 7";
    $con2 = mssql_query($con2);
    $con3 = "SET ANSI_NULLS OFF";
    $con3 = mssql_query($con3);
    $con4 = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED";
    $con4 = mssql_query($con4);
    $con5 = "SET LOCK_TIMEOUT -1";
    $con5 = mssql_query($con5);
    $con6 = "SET QUOTED_IDENTIFIER OFF";
    $con6 = mssql_query($con6);
    $con7 = "set language spanish";
    $con7 = mssql_query($con7);
}
开发者ID:Bragiel,项目名称:apmovilprueba,代码行数:26,代码来源:pedidosesp_func.php

示例7: 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;
 }
开发者ID:speedwork,项目名称:database,代码行数:35,代码来源:MssqlDriver.php

示例8: connect

 function connect()
 {
     $this->last_errno = 0;
     $this->last_error = '';
     if (isset($this->mssql)) {
         $this->dbh = @mssql_connect($this->dbhost, $this->dbuser, $this->dbpassword, true);
     } else {
         $this->dbh = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpassword, true);
     }
     if (!$this->dbh) {
         $this->ready = false;
         if (isset($this->mssql)) {
             $this->last_error = mssql_get_last_message();
             if (empty($this->last_error)) {
                 $this->last_error = 'Unable to connect to mssql: ' . $this->dbhost;
             }
             $this->last_errno = 1;
         } else {
             $this->last_error = mysql_error();
             $this->last_errno = mysql_errno();
         }
         return false;
     }
     $this->ready = true;
     $this->real_escape = true;
     $this->select($this->dbname, $this->dbh);
 }
开发者ID:ahmader,项目名称:database-php,代码行数:27,代码来源:database.php

示例9: _connect

 /**
  * Creates a connection resource.
  */
 protected function _connect()
 {
     if (is_resource($this->_connection)) {
         // connection already exists
         return;
     }
     if (!extension_loaded('mssql')) {
         throw new Exception('The mssql extension is required for this adapter but the extension is not loaded');
     }
     $serverName = $this->_config['host'];
     if (isset($this->_config['port'])) {
         $port = (int) $this->_config['port'];
         $serverName .= ', ' . $port;
     }
     $username = $password = '';
     if (isset($this->_config['username']) && isset($this->_config['password'])) {
         $username = $this->_config['username'];
         $password = $this->_config['password'];
     }
     $this->_connection = mssql_connect($serverName, $username, $password);
     if (!$this->_connection) {
         throw new Exception('Mssql Connection Error: ' . mssql_get_last_message());
     }
     if (isset($this->_config['dbname']) && !mssql_select_db($this->_config['dbname'])) {
         throw new Exception('Unable to connect or select database ' . $this->_config['dbname']);
     }
 }
开发者ID:diglin,项目名称:diglin_mssql,代码行数:30,代码来源:Mssql.php

示例10: 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('');
 }
开发者ID:eyumay,项目名称:ju.ejhs,代码行数:30,代码来源:mssql.php

示例11: __construct

 /**
  * Constructor 
  * 
  * @param $dsn string DSN for the connection
  */
 public function __construct($dsn)
 {
     $this->config = parse_url($dsn);
     if (!$this->config) {
         throw new DatabaseException("Invalid dsn '{$dsn}'.");
     }
     $database = trim($this->config['path'], '/');
     if (isset($this->config['host'])) {
         $host = $this->config['host'];
     }
     if (isset($this->config['user'])) {
         $user = $this->config['user'];
     }
     if (isset($this->config['port'])) {
         $port = $this->config['port'];
     }
     if (isset($this->config['pass'])) {
         $pass = $this->config['pass'];
     }
     $this->connection = mssql_connect($host, $user, $pass);
     if (!$this->connection) {
         throw new DatabaseException("Invalid database settings.");
     }
     if (!mssql_select_db($database, $this->connection)) {
         throw new DatabaseException("Database does not exist");
     }
 }
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:32,代码来源:mssql.php

示例12: getProductos

function getProductos()
{
    $myServer = "172.30.5.49";
    $myUser = "UsrPsg";
    $myPass = "PsGcRm1402*LaU+";
    $myDB = "LAUMAYER";
    $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on {$myServer}");
    $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database {$myDB}");
    //Realiza el query en la base de datos
    $mysqli = makeSqlConnection();
    //$sql = "SELECT * FROM psg_productos a LEFT JOIN psg_productos_cstm ac ON a.id = ac.id_c";
    $sql = "SELECT id,name FROM psg_productos where deleted ='0'";
    $res = $mysqli->query($sql);
    $rows = array();
    while ($r = mysqli_fetch_assoc($res)) {
        $obj = (object) $r;
        $querySaldo = "Select dbo.F_Saldo_Bodega_Informe(Year(GETDATE()),MONTH(GETDATE()),'" . $r['id'] . "','BODPRDCTO','T','C') as Saldo";
        $result = mssql_query($querySaldo);
        if ($row = mssql_fetch_array($result)) {
            $obj->saldo = $row['Saldo'];
        }
        $a = (array) $obj;
        $rows[] = $a;
    }
    mssql_close($dbhandle);
    if (empty($rows)) {
        return '{"results" :[]}';
    } else {
        //Convierte el arreglo en json y lo retorna
        $temp = json_encode(utf8ize($rows));
        return '{"results" :' . $temp . '}';
    }
}
开发者ID:ekutor,项目名称:hermes,代码行数:33,代码来源:getProductos.php

示例13: 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('');
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:34,代码来源:mssql.php

示例14: getDbConnect

 private function getDbConnect($address, $account, $pwd, $name)
 {
     if (DB_TYPE == 'mssql') {
         return mssql_connect($address, $account, $pwd);
     }
     if (DB_TYPE == 'sqlsrv') {
         if (defined('DBITPro_Dev')) {
             $connectionInfo = array("UID" => $account, "PWD" => $pwd, "Database" => $name);
         } else {
             $connectionInfo = array("UID" => $account, "PWD" => $pwd, "Database" => $name);
         }
         $conn = sqlsrv_connect($address, $connectionInfo);
         if (false === $conn) {
             echo "Could not connect.\n";
             die(print_r(sqlsrv_errors(), true));
         }
         return $conn;
     }
     if (DB_TYPE == 'mysql') {
         $conn = mysql_connect($address, $account, $pwd);
         if (false === $conn) {
             echo "Could not connect.\n";
             die(print_r(mysql_errors(), true));
         }
         return $conn;
     }
 }
开发者ID:bciv,项目名称:COMS,代码行数:27,代码来源:sqlquery.class.php

示例15: db_connect

 /**
  * Non-persistent database connection
  *
  * @access	private called by the base class
  * @return	resource
  */
 function db_connect()
 {
     if ($this->port != '') {
         $this->hostname .= ',' . $this->port;
     }
     return @mssql_connect($this->hostname, $this->username, $this->password);
 }
开发者ID:arifh28,项目名称:siskalite,代码行数:13,代码来源:mssql_driver.php


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