DEMO of MSSQL connection based on PDO and demo of pdomssql

Source: Internet
Author: User

DEMO of MSSQL connection based on PDO and demo of pdomssql

This example describes how to connect to MSSQL Based on PDO in php. We will share this with you for your reference. The details are as follows:

<? Phptry {$ hostname = '2017. 79.93.222 '; $ port = 1433; // port $ dbname = "csdn"; // database name $ username = "csdn_admin"; // user $ pw = "123456 "; // password $ dbh = new PDO ("dblib: host = $ hostname: $ port; dbname = $ dbname", "$ username", "$ pw ");} catch (PDOException $ e) {echo "Failed to get DB handle :". $ e-> getMessage (). "n"; exit;} echo 'connent MSSQL succeed'; $ stmt = $ dbh-> prepare ("SELECT * FROM CSDNUser"); $ stmt-> execute (); while ($ row = $ stmt-> fetch () {print_r ($ row);} unset ($ dbh); unset ($ stmt );

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.