在Out存储过程PHP MySQLi中

时间:2016-05-18 11:48:33

标签: php mysqli

我有以下PHP代码,用于通过调用存储过程将详细信息存储到表中:我希望以程序方式获取代码

$donpm = 0;
$cashCall = mysqli_prepare($dbc, 'call spCashDonation(?,@rno)');
mysqli_stmt_bind_param($cashCall, 'ssiid', $donFirstName, $donLastName, $donContactNo, $donpm, $donAmount);
mysqli_stmt_execute($cashCall) or die('Error recording Donation details.');

$getRno = mysqli_query($dbc, 'SELECT @rno');
$result = mysqli_fetch_assoc($getRno);
$ReceiptNo = $result['@rno'];

echo $ReceiptNo;

调用存储过程:

Call spCashDonation ('SAI','KUMAR',9967021655,0,10000,@rno);
select @rno as ReceiptNo;

我没有获得PHP代码的任何输出(收据号)。我第一次编写PHP代码来从MySQL调用过程。

请咨询

1 个答案:

答案 0 :(得分:0)

好的,经过一些研究后,问题似乎是mysqli_prepare语句:参数不正确。

以下是精炼代码:

$donpm = 0;
$cashCall = mysqli_prepare($dbc, 'call spCashDonation(?,?,?,?,?,@rno)');
mysqli_stmt_bind_param($cashCall, 'ssiid', $donFirstName, $donLastName, $donContactNo, $donpm, $donAmount);
mysqli_stmt_execute($cashCall) or die('Error recording Donation details.');

$getRno = mysqli_query($dbc, 'SELECT @rno');
$result = mysqli_fetch_assoc($getRno);
$ReceiptNo = $result['@rno'];

echo $ReceiptNo;
echo $donFirstName . ' ' . $donLastName . ' ' . $donContactNo . ' ' . $donpm . ' ' . $donAmount;