Php uses pdo to connect to the mssqlserver database instance

Source: Internet
Author: User
Tags mssql server mssqlserver
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.