This article mainly introduces how to use pdo to connect to the mssqlserver database in php, and analyzes the skills of using pdo to connect to the mssqlserver database in php as an example, which is very simple and practical, for more information about how to use php pdo to connect to Microsoft's mssql server database, see the example in this article. The specific implementation method is as follows:
The code is as follows:
$ Dsn = 'mssql: dbname = bookStore_demo; host = 192.168.1.106 ';
$ User = 'sa ';
$ Password = '000000 ';
// Mssql_connect ('192. 168.1.106 ', 'sa', '123 ');
// Echo 22;
Try {
// Echo 11;
$ Dbh = new PDO ($ dsn, $ user, $ password );
} Catch (PDOException $ e ){
Echo 'connection failed: '. $ e-> getMessage ();
}
// $ SQL = 'select * from article ';
$…… = $ Dbh-> query ($ SQL );
$ Result = $ Something-> fetchAll ();
Var_dump ($ result );
I hope this article will help you with PHP programming.