Skip to content

snippets.md

PDO connection to a MSSQL Server

PHP
1
2
3
4
5
$addr = '127.0.0.1\SQLEXPRESS';
$usr = 'sa';
$pwd = readline('Enter Password: ');
$obj = new PDO("sqlsrv:Server=$addr", $usr, $pwd);
echo $obj->query('SELECT @@VERSION')->fetch(PDO::FETCH_COLUMN);