(PHP 5, PHP 7)
mysqli::multi_query -- mysqli_multi_query — ִ�в�ѯ
���������
$query
) : bool���̻����
ִ��һ�� SQL ��䣬���߶��ʹ�÷ֺŷָ��� SQL ��䡣
Ҫ���ִ�н���еĵ�һ�����������ʹ�� mysqli_use_result() �� mysqli_store_result() ������ Ҫ��ȡ�����Ľ������ ��ʹ�� mysqli_more_results() �� mysqli_next_result() ������
link
���Թ��̻���ʽ����mysqli_connect() �� mysqli_init() ���ص����ӱ�ʶ��
query
��ѯ��䡣
��ѯ����е�����һ��Ҫ��ȷ�Ľ��� ת����
�����һ�� SQL ����ʧ���ˣ����� FALSE
��
���������ִ�� SQL ��䣬
�������ȵ��� mysqli_next_result() �������ſ��Ի�ȡ�������Ĵ�����Ϣ��
Example #1 mysqli::multi_query() ����
���������
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* ������� */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
/* ����ִ�в�ѯ */
if ($mysqli->multi_query($query)) {
do {
/* store first result set */
if ($result = $mysqli->store_result()) {
while ($row = $result->fetch_row()) {
printf("%s\n", $row[0]);
}
$result->free();
}
/* print divider */
if ($mysqli->more_results()) {
printf("-----------------\n");
}
} while ($mysqli->next_result());
}
/* �ر����� */
$mysqli->close();
?>
���̻����
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* ������� */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
/* ����ִ�в�ѯ */
if (mysqli_multi_query($link, $query)) {
do {
/* store first result set */
if ($result = mysqli_store_result($link)) {
while ($row = mysqli_fetch_row($result)) {
printf("%s\n", $row[0]);
}
mysqli_free_result($result);
}
/* print divider */
if (mysqli_more_results($link)) {
printf("-----------------\n");
}
} while (mysqli_next_result($link));
}
/* �ر����� */
mysqli_close($link);
?>
�������̵���������ڣ�
my_user@localhost ----------------- Amersfoort Maastricht Dordrecht Leiden Haarlemmermeer