选择不在存储过程后执行

时间:2014-12-24 08:39:28

标签: php mysql sql stored-procedures

我有以下两个PHP命令:

$binding_result = mysqli_query
(
    $con, 
    "SELECT b.normal_group, b.normal_action, b.shift_group, b.shift_action, b.ctrl_group, b.ctrl_action, b.alt_group, b.alt_action, b.altgr_group, b.altgr_action, b.extra_group, b.extra_action, b.image_file, b.key_number
    FROM    bindings as b
    WHERE   b.layout_id = " . $layout_id . "
    AND b.game_id = " . $game_id . ";"
);
$legend_result = mysqli_query
(
    $con,
    "SELECT l.legend_group, l.legend_description
    FROM    legends as l
    WHERE   l.layout_id = " . $layout_id . "
    AND l.game_id = " . $game_id . ";"
);

他们的工作很好。但是,当我通过调用存储过程替换第一个命令时,第二个脚本不会被执行。例如。以下不起作用:

$binding_result = mysqli_query($con, "CALL get_bindings(" . $layout_id . ", " . $game_id . ")");
$legend_result = mysqli_query
(
    $con,
    "SELECT l.legend_group, l.legend_description
    FROM    legends as l
    WHERE   l.layout_id = " . $layout_id . "
    AND l.game_id = " . $game_id . ";"
);

以下是存储过程的内容:

CREATE PROCEDURE `get_bindings`(IN in_layout_id TINYINT(3), IN in_game_id SMALLINT(5))
BEGIN
    SELECT  b.normal_group, b.normal_action, b.shift_group, b.shift_action, b.ctrl_group, b.ctrl_action, b.alt_group, b.alt_action, b.altgr_group, b.altgr_action, b.extra_group, b.extra_action, b.image_file, b.key_number
    FROM    bindings as b
    WHERE   b.layout_id = in_layout_id
    AND     b.game_id = in_game_id;
END

以下是错误:

[24-Dec-2014 03:00:47 America/Chicago] PHP Warning:  mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/isometr1/public_html/keyboard/keyboardchart.php on line 178
[24-Dec-2014 03:00:47 America/Chicago] PHP Warning:  mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/isometr1/public_html/keyboard/keyboardchart.php on line 182
[24-Dec-2014 03:00:47 America/Chicago] PHP Warning:  mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/isometr1/public_html/keyboard/keyboardchart.php on line 201
[24-Dec-2014 03:00:47 America/Chicago] PHP Warning:  mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/isometr1/public_html/keyboard/keyboardchart.php on line 303

以下是获取行内容:

while ($temp_row = mysqli_fetch_row($binding_result))
{
    $binding_table[$temp_row[13]] = $temp_row;
}
while ($temp_row = mysqli_fetch_row($legend_result))
{
    $legend_table[] = $temp_row;
}

0 个答案:

没有答案