首页 >后端开发 >php教程 >例子:用PHP3调用Microsoft SQL Server的存储过程_PHP教程

例子:用PHP3调用Microsoft SQL Server的存储过程_PHP教程

WBOY
WBOY原创
2016-07-13 11:00:14879浏览

存储过程(procedure.sql):
  create procedure hello
      @yourname varchar(50) = "无名士"
  as
  select @yourname + ",你好!"
  go
PHP3程序(procedure.php3):
  
  $server = mssql_connect("localhost","sa","") or die("无法连接数据库服务器!");
  $db = mssql_select_db("test",$server) or die("无法连接test数据库!");
  echo "

";
  echo "";
  $query = "exec hello @yourname="朋友"";
  $rst = mssql_query($query,$db) or die("无法执行SQL:$query");
  $fields_num = mssql_num_fields($rst);
  $i=0;
  while($i          $fields[$i] = mssql_field_name($rst,$i);
          echo "";
          $i++;
  }
  echo "";
  while ($record=mssql_fetch_array($rst)) {
       echo "";
       $i=0;
       while($i       $value = $record[$fields][$i]];
       if($value=="")
          echo "";
       else
          echo "";
       $i++;
       }
       echo "";
  }
  mssql_free_result($rst);
  echo "
" . $fields[$i] . "
 " . $value    . "
";
  
  mssql_close($server) or die("无法与数据库服务器断开连接!");
  ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631832.htmlTechArticle存储过程(procedure.sql): create procedure hello @yourname varchar(50) = 无名士 as select @yourname + ,你好! go PHP3程序(procedure.php3): ? $server = mssql_connect...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn