Showing posts with label PHP Installer. Show all posts
Showing posts with label PHP Installer. Show all posts

Thursday, June 18, 2020

Microsoft ODBC Driver for SQL Server

Untuk connection kepada database Microsoft SQL Server di dalam Windows, Linux, & macOS perlu ada ODBC driver.  


Untuk check ODBC driver ada atau tak dalam server, tengok di sini :



ODBC driver ada banyak version, yang terkini adalah 17.

Dah install driver bolehlah buat connection, contoh connection database di dalam PHP :

### Database    ###
$user = "xx"; //database user
$pass = "xx";    //database password
$host = "xx";   //database location
$db = "xx";     //database name

$mssqldriver = '{ODBC Driver 13 for SQL Server}';

try {

$conn = new PDO("sqlsrv:Driver=$mssqldriver;Server=$host;Database=$db", $user, $pass);

} catch (PDOException $e) {

    echo $e->getMessage();
}




$conn = odbc_connect("DRIVER=SQL Server;Server=$host;Database=$db;", $user, $pass)or die("Cant connect");


Download untuk PHP drivers (cth : pdo_sqlsrv 5.6.0 for Windows)

PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.
The packaging and distribution system used by PECL is shared with its sister, PEAR.