mysqli fetch all - 语法

mysqli_fetch_all(result,resulttype);

它用于提取所有输出行,并将输出集作为关联数组返回

Sr.No 参数 & Description
1

result

它指定输出集标识符

2

resulttype

它指定应该生成的数组类型

mysqli fetch all - 返回值

它返回一个包含输出行的关联数组。

mysqli fetch all - 示例

<?php
   $connection_mysql=mysqli_connect("localhost","user","pass","db");
   
   if (mysqli_connect_errno($connection_mysql)){
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
   
   $sql="SELECT name FROM emp";
   $result=mysqli_query($connection_mysql,$sql);
   
   mysqli_fetch_all($result,MYSQLI_ASSOC);
   mysqli_free_result($result);
   mysqli_close($connection_mysql);
?>

参考链接

https://www.learnfk.com/php/php-mysqli-fetch-all.html