我有一个在MSSQL 2008 R2中运行的存储过程,我使用PHP 5.3,我可以成功连接到数据库并检索数据,但我一直在尝试调用存储过程,没有成功,我需要传递参数到存储过程,然后在这里得到结果是我的代码,但它不能成功执行。任何人请与我如何做到这一点的例子。调用MS SQL存储过程从PHP
<?PHP
$sql = " { call rpt_TOP_PRODUCTS } ";//my stored procedure
$param1 = 10;
$param2 = 'E';
$param3 = 'SZ';
$params = Array(Array($param1,$param2,$param3, SQLSRV_PARAM_IN)//parameters to be passed );
$stmt = sqlsrv_query($conn,$sql,$params);
if ($stmt===false) {
// handle error
echo 'Success No';//THIS IS WHERE ITS GOING WHEN I RUN THE CODE
print_r(sqlsrv_errors,true);
} else {
if (sqlsrv_execute($stmt)===false) {
// handle error. This is where the error happens
print_r(sqlsrv_errors,true);
echo 'Success Not ';
} else {
echo 'Success True Yeah';//THIS IS WHERE I WANT IT TO COME.
}
}
<?