以前は MYSql に PDO を使用していましたが、現在は Microsoft SQL Server Driver for PHP を使用する必要があります。
マニュアルを見つけました。 http://php.net/manual/en/book.sqlsrv.php
例 2 を使用して新しい SQL データベースに接続します: http://www.php.net/manual/en/function.sqlsrv-connect.php
次の (PDO mysql) を sqlsrv で動作するように「変換」するにはどうすればよいですか。
$username = 'test';
try {
$conn = new PDO('mysql:host=$host;dbname=$database', $username, password);
$stmt = $conn->prepare('SELECT username users WHERE username = :username LIMIT 1');
$stmt->execute(array('username' => $username));
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch();
echo $result['username'];
} else {
echo 'Nothing found.';
die();
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}