在PHP中执行存储过程不起作用

时间:2022-09-20 23:47:41

We are currently using this PHP code in order to query a view however, we want this to now execute a stored procedure.

我们目前正在使用这个PHP代码来查询视图,但是我们希望现在执行存储过程。

$sMSSQLQuery = "SELECT * FROM [reporting].[dbo].Report_thereport_cc;";

$aResults = RunMSSQLQuery($sMSSQLQuery);

echo json_encode($aResults);

When we try and run the above against a stored procedure, we get a Database Query Error. What do we need to change in order for it to work?

当我们尝试针对存储过程运行上述操作时,我们会收到数据库查询错误。我们需要改变什么才能使其发挥作用?

1 个解决方案

#1


If you execuse Store Procedure you must use EXEC statement like this

如果您执行Store Procedure,则必须使用这样的EXEC语句

EXEC storeProcedure1

I'm not sure when use with php but try this

我不确定何时使用php但试试这个

$sMSSQLQuery = "EXEC [reporting].[dbo].Report_thereport_cc;";

$aResults = RunMSSQLQuery($sMSSQLQuery);

echo json_encode($aResults);

#1


If you execuse Store Procedure you must use EXEC statement like this

如果您执行Store Procedure,则必须使用这样的EXEC语句

EXEC storeProcedure1

I'm not sure when use with php but try this

我不确定何时使用php但试试这个

$sMSSQLQuery = "EXEC [reporting].[dbo].Report_thereport_cc;";

$aResults = RunMSSQLQuery($sMSSQLQuery);

echo json_encode($aResults);