PHP使用PDO調(diào)用mssql存儲過程的方法示例
本文實例講述了PHP使用PDO調(diào)用mssql存儲過程的方法。分享給大家供大家參考,具體如下:
數(shù)據(jù)庫中已創(chuàng)建存儲過程user_logon_check, PHP調(diào)用示例如下,
<?php
$dsn = 'mssql:dbname=MyDbName;host=localhost';
$user = 'sa';
$password = '666666';
try {
$dbCon = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: '.$e->getMessage();
exit;
}
$username = '123';
$userpsw = '123';
//$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>";
}
?>
更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP基于pdo操作數(shù)據(jù)庫技巧總結(jié)》、《php+Oracle數(shù)據(jù)庫程序設計技巧總結(jié)》、《PHP+MongoDB數(shù)據(jù)庫操作技巧大全》、《php面向?qū)ο蟪绦蛟O計入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家PHP程序設計有所幫助。
相關(guān)文章
php通過分類列表產(chǎn)生分類樹數(shù)組的方法
這篇文章主要介紹了php通過分類列表產(chǎn)生分類樹數(shù)組的方法,涉及php操作數(shù)組與分類節(jié)點的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-04-04
PHP實現(xiàn)自動識別原編碼并對字符串進行編碼轉(zhuǎn)換的方法
這篇文章主要介紹了PHP實現(xiàn)自動識別原編碼并對字符串進行編碼轉(zhuǎn)換的方法,涉及php針對編碼的識別、轉(zhuǎn)換及數(shù)組的遍歷等相關(guān)操作技巧,需要的朋友可以參考下2016-07-07
PHP字符串與數(shù)組處理函數(shù)用法小結(jié)
這篇文章主要介紹了PHP字符串與數(shù)組處理函數(shù)用法,結(jié)合實例形式詳細分析了PHP字符串與數(shù)組常用處理函數(shù)功能、定義、使用方法與操作注意事項,需要的朋友可以參考下2020-01-01
PHP獲取數(shù)組表示的路徑方法分析【數(shù)組轉(zhuǎn)字符串】
這篇文章主要介紹了PHP獲取數(shù)組表示的路徑,結(jié)合實例形式對比分析了數(shù)組轉(zhuǎn)字符串的實現(xiàn)技巧,需要的朋友可以參考下2017-09-09

