对我来说,这确实是好的,它将处理(作为例子)像你们的《特殊标准》中那样的许多挑选名单。 请注意,你必须如何关闭你从下至下期的预支款。
?><pre><?
$call = mysqli_prepare($db, CALL test_lists(?, ?, @result) );
if($call == false) {
echo "mysqli_prepare ($db, CALL test_lists(?, ?, @result) FAILED!!!
";
} else {
// A couple of example IN parameters for your SP...
$s_1 = 4;
$s_2 = "Hello world!";
// Here we go (safer way of avoiding SQL Injections)...
mysqli_stmt_bind_param($call, is , $s_1, $s_2);
// Make the call...
if(mysqli_stmt_execute($call) == false) {
echo "mysqli_stmt_execute($call) FAILED!!!
";
} else {
//print_r($call);
// Loop until we run out of Recordsets...
$set = 0;
while ($recordset = mysqli_stmt_get_result($call)) {
++$set;
//print_r($recordset);
echo "
Recordset #" . $set . "...
";
if ($recordset->num_rows > 0) {
$ctr = 0;
while ($row = $recordset->fetch_assoc()) {
++$ctr;
//print_r($row);
echo " " . $ctr . ": ";
forEach($row as $key => $val) {
echo "[" . $key . "] " . $val . " ";
}
echo "
";
}
}
echo $recordset->num_rows . " record" . ($recordset->num_rows == 1 ? "" : "s") . ".
";
// Clean up, ready for next iteration...
mysqli_free_result($recordset);
// See if we can get another Recordset...
mysqli_stmt_next_result($call);
}
// Then you have to close the $call...
mysqli_stmt_close($call);
// ...in order to get to the SP s OUT parameters...
$select = mysqli_query($db, "SELECT @result");
$row = mysqli_fetch_row($select);
$result = $row[0];
echo "
OUT @result = " . $result . "
";
}
}
?></pre><?
而这正是上述法典的产出所看的,是使用我的标准——清单SP......。
Recordset #1...
1: [s_1] 4 [user_name] Andrew Foster
2: [s_1] 4 [user_name] Cecil
3: [s_1] 4 [user_name] Sheff
3 records.
Recordset #2...
1: [s_2] Hello world! [section_description] The Law
2: [s_2] Hello world! [section_description] History
3: [s_2] Hello world! [section_description] Wisdom Literature
4: [s_2] Hello world! [section_description] The Prophets
5: [s_2] Hello world! [section_description] The Life of Jesus and the Early Church
6: [s_2] Hello world! [section_description] Letters from the Apostle Paul
7: [s_2] Hello world! [section_description] Other Letters from Apostles and Prophets
8: [s_2] Hello world! [section_description] Prophecy - warnings for the present and revelation of the future
8 records.
OUT @result = 16