1. 数据库中已创建存储过程user_logon_check, PHP调用示例如下,
- <?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>";
- }
- ?>