我正在尝试使用pdo sql_srv
远程连接到mssql服务器,但我仍然通过fallwoing得到错误。 PDOException :
SQLSTATE [08001]:[Microsoft] [SQL Server的ODBC驱动程序11] TCP 提供程序:尝试以禁止的方式访问套接字 它的访问权限。
我还启用了防火墙和服务器配置TCP端口。
class Database {
public $error;
public $ok;
public $dead;
var $query_id;
var $LastPDOResult;
var $La
stPDOResultCursor;
var $SQLDebug;
var $sql;
// Constructor --> Connect
function __construct($SQLHOST, $SQLPORT, $SQLDB, $SQLUSER, $SQLPWD) {
try {
if(PDODRIVER == 3) {
$this->db = new PDO("odbc:Driver={SQL Server};Server=".$SQLHOST.";Database=".$SQLDB."; Uid=".$SQLUSER.";Pwd=".$SQLPWD.";");
} else {
if(PDODRIVER == 2) {
$pdo_connect = "sqlsrv:Server=".$SQLHOST.",".$SQLPORT.";Database=".$SQLDB."";
} else {
$pdo_connect = 'dblib:host='.$SQLHOST.':'.$SQLPORT.';dbname='.$SQLDB;
}
$this->db = new PDO($pdo_connect, $SQLUSER, $SQLPWD);
}
} catch (PDOException $e) {
$this->dead = true;
$this->error = "PDOException: ".$e->getMessage();
if(config('ERROR_REPORTING',true)) {
die($this->error);
} else {
//die('website offline');
die($this->error);
}
}
}
}
$dB = new Database(DBHOST, DBPORT, DBNAME, DBUSER, DBPASS);