PHP mysqli_multi_query() 函数

PHP 教程 · 2019-01-28 08:59:42

实例

执行多个针对数据库的查询:

<?php $con=mysqli_connect("localhost","my_user","my_password","my_db"); // 检测链接 if (mysqli_connect_errno($con)) { echo "连接到 MySQL 失败: " . mysqli_connect_error(); } $sql = "SELECT Lastname FROM Persons ORDER BY LastName;"; $sql .= "SELECT Country FROM Customers"; // 执行多个 SQL 语句 if (mysqli_multi_query($con,$sql)) { do { // 存储第一个结果集 if ($result=mysqli_store_result($con)) { while ($row=mysqli_fetch_row($result)) { printf("%sn",$row[0]); } mysqli_free_result($result); } } while (mysqli_next_result($con)); } mysqli_close($con); ?>

定义和用法

mysqli_multi_query() 函数执行一个或多个针对数据库的查询。多个查询用分号进行分隔。

语法

mysqli_multi_query(connection,query);

参数 描述
connection 必需。规定要使用的 MySQL 连接。
query 必需。规定一个或多个查询,用分号进行分隔。

技术细节

返回值: 如果第一个查询失败则返回 FALSE。
PHP 版本: 5+

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Rework

Rework

Jason Fried、David Heinemeier Hansson / Crown Business / 2010-3-9 / USD 22.00

"Jason Fried and David Hansson follow their own advice in REWORK, laying bare the surprising philosophies at the core of 37signals' success and inspiring us to put them into practice. There's no jarg......一起来看看 《Rework》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具