我正在使用的一些 PHP 和 MSSQL 遇到了一个非常奇怪的问题。我正在使用存储过程来检索用户刚刚存储到数据库中的信息,以便他们可以打印出他们的条目记录。
最初,我在将标题详细信息显示在屏幕上时遇到问题,因此最终通过将 $skip_results 的布尔值设置为 true 来更改代码以使其正常工作。这意味着我必须在没有该设置的情况下第二次调用存储过程来获取相关的信息行。
这是我所做的:
//populate header with order information - this one uses true in the mssql_execute in order to return all the output variables
/* prepare the statement resource */
$confirmationstmt=mssql_init("stored-procedure-name", $link);
/* now bind the parameters to it */
mssql_bind($confirmationstmt, "@var1", $var1, SQLVARCHAR, FALSE);
mssql_bind($confirmationstmt, "@var2", $var2, SQLFLT8, TRUE);
mssql_bind($confirmationstmt, "@var3", $var3, SQLVARCHAR, TRUE);
mssql_bind($confirmationstmt, "@var4", $var4, SQLVARCHAR, TRUE);
mssql_bind($confirmationstmt, "@var5", $var5, SQLVARCHAR, TRUE);
mssql_bind($confirmationstmt, "@var6", $var6, SQLVARCHAR, TRUE);
mssql_bind($confirmationstmt, "@var7", $var7, SQLVARCHAR, TRUE);
mssql_bind($confirmationstmt, "@var8", $var8, SQLINT4, TRUE);
mssql_bind($confirmationstmt, "@var9", $var9, SQLVARCHAR, true);
mssql_bind($confirmationstmt, "@var10", $var10, SQLFLT8, true);
mssql_bind($confirmationstmt, "@var11", $var11, SQLFLT8, true);
mssql_bind($confirmationstmt, "@var12", $var12, SQLFLT8, true);
mssql_bind($confirmationstmt, "@var13", $var13, SQLFLT8, true);
// now execute the procedure
$confirmationresult = mssql_execute($confirmationstmt, true);
//populate header with order information - this one uses true in the mssql_execute in order to return all the output variables
/* prepare the statement resource */
$numlinesstmt=mssql_init("stored-procedure-name", $link);
/* now bind the parameters to it */
mssql_bind($numlinesstmt, "@var1", $var1, SQLVARCHAR, FALSE);
mssql_bind($numlinesstmt, "@var2", $var2, SQLFLT8, TRUE);
mssql_bind($numlinesstmt, "@var3", $var3, SQLVARCHAR, TRUE);
mssql_bind($numlinesstmt, "@var4", $var4, SQLVARCHAR, TRUE);
mssql_bind($numlinesstmt, "@var5", $var5, SQLVARCHAR, TRUE);
mssql_bind($numlinesstmt, "@var6", $var6, SQLVARCHAR, TRUE);
mssql_bind($numlinesstmt, "@var7", $var7, SQLVARCHAR, TRUE);
mssql_bind($numlinesstmt, "@var8", $var8, SQLINT4, TRUE);
mssql_bind($numlinesstmt, "@var9", $var9, SQLVARCHAR, true);
mssql_bind($numlinesstmt, "@var10", $var10, SQLFLT8, true);
mssql_bind($numlinesstmt, "@var11", $var11, SQLFLT8, true);
mssql_bind($numlinesstmt, "@var12", $var12, SQLFLT8, true);
mssql_bind($numlinesstmt, "@var13", $var13, SQLFLT8, true);
// now execute the procedure
$numlinesresult = mssql_execute($numlinesstmt);
$numlines = mssql_num_rows($numlinesresult);
第一组 mssql_bind 语句中的变量都已正确填充,虽然您希望第二次调用会覆盖它们,但它们没有!当我第一次将这个“修复”应用到站点时,$numlines 变量被正确填充,这使我能够处理存储过程创建的 select 语句返回的所有行。然而,24 小时后,第二组停止工作,我从 mssql_num_rows($numlinesresult) 调用中得到一个 0。
谁能告诉我在这里做错了什么,因为我真的不应该两次调用存储过程,每次都以不同的方式来获取所有信息。
提前致谢!