从 php 调用 MySQL 存储过程时出现问题
我有一个存储的 MySQL 过程,它接受客户编号和货币作为输入。它使用 select 语句输出一个数组。输出数组由 Balance 和 NetBalance 组成,
如果我从 MySQL 调用该过程“call GetAccountBalanceByCurrency(500,'USD')
”,我会得到正确的结果。
但是,如果我从 PHP 中调用它 $x= mysqli_multi_query("call GetAccountBalanceByCurrency(500,'USD');")
,我会收到以下错误消息:
Warning: mysqli_multi_query() expects exactly 2 parameters, 1 given
in C:\...\...\call_proc_test4.php on line 4.
我认为这很简单,但是已经敲了我的头好几个小时了。我已经尝试过 $x= mysqli_multi_query("call GetAccountBalanceByCurrency(500,'USD')");
除其他事项外。有人能看到错误吗?
非常感谢。
I have a stored MySQL procedure that takes a customer number and a currency as input. It outputs an array using a select statement. The output array is comprised of Balance and NetBalance,
If I call the procedure from MySQL as "call GetAccountBalanceByCurrency(500,'USD')
" I get the correct results.
However, if I call it from PHP as $x= mysqli_multi_query("call GetAccountBalanceByCurrency(500,'USD');")
, I get the following error message:
Warning: mysqli_multi_query() expects exactly 2 parameters, 1 given
in C:\...\...\call_proc_test4.php on line 4.
I assume it is something simple, but have been banging my head for hours. I have tried $x= mysqli_multi_query("call GetAccountBalanceByCurrency(500,'USD')");
among other things. Can anybody see the error?
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
引用手册,
mysqli_multi_query
函数当您使用过程式 API 时,需要两个参数:因此,您至少必须将链接标识符作为第一个参数传递。
顺便说一句:这正是警告消息试图向您表明的内容;-)
“
mysqli_multi_query()
期望恰好 2 个参数,给定 1”是的,同一手册页还给出了一个只有一个参数的示例——但它是面向对象风格的(mysqli 是一个公开过程 API 和 OO API 的扩展)。
Quoting the manual, the
mysqli_multi_query
function requires two parameters, when you are using the procedural style API :So, you at least must pass the link identifier as a first parameter.
BTW : that's exactly what the warning message is trying to indicate you ;-)
"
mysqli_multi_query()
expects exactly 2 parameters, 1 given"Yes, the same manual page also gives an example with only one parameter -- but it's for the Object oriented style (mysqli being an extension that exposes both a procedural and an OO API).
查看 mysqli_multi_query 的文档。您调用它的方式需要两个参数,而不仅仅是一个:
https://www.php.net/ mysqli_multi_query
Check out the documentation for mysqli_multi_query. The way you're calling it needs two arguments instead of just the one:
https://www.php.net/mysqli_multi_query
首先您必须设置 2 个查询或一个资源和一个查询
像这样
First you have to set 2 querys or one recource and one query
like this