多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# PHP mysqli_multi_query() 函数 ## 实例 执行多个针对数据库的查询: ``` <?php $con=mysqli_connect("localhost","my_user","my_password","my_db"); // Check connection if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql = "SELECT Lastname FROM Persons ORDER BY LastName;"; $sql .= "SELECT Country FROM Customers"; // Execute multi query if (mysqli_multi_query($con,$sql)) { do { // Store first result set if ($result=mysqli_store_result($con)) { while ($row=mysqli_fetch_row($result)) { printf("%sn",$row[0]); } mysqli_free_result($con); } } while (mysqli_next_result($con)); } mysqli_close($con); ?> ``` ## 定义和用法 mysqli_multi_query() 函数执行一个或多个针对数据库的查询。多个查询用分号进行分隔。 ## 语法 mysqli_multi_query(_connection,query_)_;_ | 参数 | 描述 | | --- | --- | | _connection_ | 必需。规定要使用的 MySQL 连接。 | | _query_ | 必需。规定一个或多个查询,用分号进行分隔。 | ## 技术细节 | 返回值: | 如果第一个查询失败则返回 FALSE。 | | :-- | --- | | PHP 版本: | 5+ | | :-- | --- |