mysqli_fetch_array($link, $query) 直接查询数据库时未输出预期结果

mysqli_fetch_array($link, $query) is not outputting the expected result when querying database directly

我正在尝试为每个 column_name 创建一个 table 评论数组,其中 column_name 是关键。

我转到我的 mysql 数据库 (Maria DB) 并输入查询

SELECT column_name, column_comment FROM information_schema.columns WHERE table_name='apple_checklists'

和returns两栏信息:

当我使用 phpcode 时:

$columnCommentQuery = "SELECT column_name, column_comment FROM information_schema.columns WHERE table_name='apple_checklists'";

$columnComments= mysqli_fetch_array(mysqli_query($link, $columnCommentQuery), MYSQLI_BOTH);

echo($columnCommentQuery." is_Null ".is_null($columnComments). " after ");

print_r($columnComments);

这是我得到的输出:

我不明白为什么我没有将查询结果作为数组的输出?!?!本来我每次需要评论的时候都会抓取评论,但我宁愿一次抓取所有评论然后在页面内部查看数组。

我试图表达清楚,但如果需要更多上下文,请让我know.I无法包含图片,因为我的声誉不够高。

$results = array();

while($columnComments= mysqli_fetch_array(mysqli_query($link, $columnCommentQuery), MYSQLI_BOTH)){
     array_push($results,$columnComments);
}

print_r($results);
$columnCommentQuery = "SELECT column_name, column_comment FROM information_schema.columns WHERE table_name='apple_checklists'";

$result = mysqli_query($link, $columnCommentQuery);

if ($result) {
    $columnComments= mysqli_fetch_all($result , MYSQLI_BOTH);
    print_r($columnComments);
} else {
    echo('Query: '.$columnCommentQuery.' is wrong ');
}