Example of how PHP uses PDO to call the mssql Stored Procedure, pdomssql

Source: Internet
Author: User
Tags dsn

Example of how PHP uses PDO to call the mssql Stored Procedure, pdomssql

This example describes how PHP uses PDO to call the mssql Stored Procedure. We will share this with you for your reference. The details are as follows:

The stored procedure user_logon_check has been created in the database. The PHP call example is as follows,

<? Php $ dsn = 'mssql: dbname = MyDbName; host = localhost'; $ user = 'sa '; $ password = '2016 '; try {$ dbCon = new PDO ($ dsn, $ user, $ password);} catch (PDOException $ e) {print 'Connection failed :'. $ e-> getMessage (); exit;} $ username = '000000'; $ userpsw = '000000 '; // $ xp_userlogon = $ dbCon-> query ("exec user_logon_check '$ username', '$ userpsw'"); // mysql-> call user_logon_check (' $ username ', '$ userpsw'); // mysql-> Call user_logon_check (?,?) $ Xp_userlogon = $ dbCon-> prepare ('exec user_logon_check ?,? '); $ Xp_userlogon-> bindParam (1, $ username); $ xp_userlogon-> bindParam (2, $ userpsw); $ xp_userlogon-> execute (); $ uCol = $ xp_userlogon-> columnCount (); echo $ uCol. "<br>"; while ($ row = $ xp_userlogon-> fetch () {for ($ I = 0; $ I <$ uCol; $ I ++) print $ row [$ I]. ""; print "<br>" ;}?>

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.