将结果集作为数组获取

I have some functions like this:

function doLegends($in_result)
{
    global $legend_table;
    while ($temp_row = mysqli_fetch_row($in_result))
    {
        $legend_table[] = $temp_row;
    }
}

They add each row one-by-one into a PHP array. Is there a way to save the resultset as an array in one single step without needing to get each row individually? Also, is there a performance benefit? Thanks.

[edit]

Here is the query.

SELECT  l.legend_group, l.legend_description
FROM    legends as l
WHERE   l.record_id = in_record_id;

record_id is not unique or a primary key, so it returns multiple rows.

[edit]

Is this the correct syntax?

function doLegends($in_result)
{
    global $legend_table;
    $legend_table = mysqli_fetch_array($in_result);
}

I get an syntax error, unexpected '}' error at the last line.

[edit]

Okay, the syntax error was a false positive. However, now the mysqli_fetch_array function is only returning a subset of the expected result. For instance, $legend_table should have 6 rows, but the function is only returning 2 rows. There are gaps in the SQL IDs. Some numbers are skipped due to having deleted some rows. Can this have an effect?

[edit]

Here are the contents of my SQL table:

legend_id,record_id,legend_group,legend_description
896,180,1,"Unit Actions"
897,180,2,Lenses
898,180,4,Multiplayer
899,180,5,Camera
900,180,6,"Game Screens"
901,180,8,"Game Commands"

But when I count the number of rows using this:

error_log("woot " . count($legend_table));

the error log only shows woot 4 instead of woot 6.

You can make use of mysqli_fetch_array to get the result in array format or mysqli_fetch_assoc to get the result in associative array format