ODBC for SQL 2000
發表於 : 2018-05-19 17:56:38
https://stackoverflow.com/questions/226 ... erver-2000
代碼: 選擇全部
<?php
class SqlServerPdo {
private static $dbName = 'dbName' ;
private static $dbHost = '127.0.0.1';
private static $dbUsername = 'username';
private static $dbUserPassword = 'password';
private static $conn = null;
public function __construct() {
die('Init function is not allowed');
}
public static function connect() {
// One connection through whole application
if ( null == self::$conn ) {
try {
self::$conn = new PDO("odbc:Driver={SQL Server};Server=SERVER-NAME;Database=" . self::$dbName . ";User Id=" . self::$dbUsername . ";Password=" . self::$dbUserPassword . ";");
} catch(PDOException $e) {
die($e->getMessage());
}
}
return self::$conn;
}
public static function disconnect() {
self::$conn = null;
}
}