从 php 调用 MySQL 存储过程时出现问题

发布于 2024-08-12 15:40:36 字数 603 浏览 4 评论 0原文

我有一个存储的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

番薯 2024-08-19 15:40:36

引用手册,mysqli_multi_query函数当您使用过程式 API 时,需要两个参数:

bool mysqli_multi_query  ( mysqli $link  , string $query  )

因此,您至少必须将链接标识符作为第一个参数传递。

顺便说一句:这正是警告消息试图向您表明的内容;-)

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 :

bool mysqli_multi_query  ( mysqli $link  , string $query  )

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).

惜醉颜 2024-08-19 15:40:36

查看 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

薄暮涼年 2024-08-19 15:40:36

首先您必须设置 2 个查询或一个资源和一个查询
像这样

$link = mysqli_connect("localhost", "my_user", "my_password", "world");

$query  = "CREATE TABLE....;...;... blah blah blah;...";

mysqli_multi_query($link,$query);

First you have to set 2 querys or one recource and one query
like this

$link = mysqli_connect("localhost", "my_user", "my_password", "world");

$query  = "CREATE TABLE....;...;... blah blah blah;...";

mysqli_multi_query($link,$query);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文