PHP mysqli more_results() 함수
예 - 객체 지향 스타일
데이터베이스에 대해 여러 쿼리를 수행합니다.
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
$sql = "SELECT Lastname FROM Persons ORDER BY LastName;";
$sql .= "SELECT Country FROM Customers";
// Execute multi query
if ($mysqli
-> multi_query($sql)) {
do {
// Store first result set
if ($result =
$mysqli -> store_result()) {
while ($row =
$result -> fetch_row()) {
printf("%s\n", $row[0]);
}
$result
-> free_result();
}
// if there are more result-sets, the print a
divider
if ($mysqli -> more_results()) {
printf("-------------\n");
}
//Prepare next result set
} while ($mysqli
-> next_result());
}
$mysqli -> close();
?>
하단의 절차적 스타일의 예를 보십시오.
정의 및 사용
more_results() / mysqli_more_results() 함수는 다중 쿼리에서 더 많은 쿼리 결과가 있는지 확인합니다.
통사론
객체 지향 스타일:
$mysqli ->
more_results()
절차 스타일:
mysqli_more_results(connection)
매개변수 값
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
기술적 세부 사항
반환 값: | multi_query() 에서 사용할 수 있는 하나 이상의 결과 집합이 있는 경우 TRUE 입니다. 그렇지 않으면 거짓 |
---|---|
PHP 버전: | 5+ |
예 - 절차 스타일
데이터베이스에 대해 여러 쿼리를 수행합니다.
<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
$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("%s\n", $row[0]);
}
mysqli_free_result($result);
}
// if there are more result-sets, the print a
divider
if (mysqli_more_results($con)) {
printf("-------------\n");
}
//Prepare next result set
} while (mysqli_next_result($con));
}
mysqli_close($con);
?>
❮ PHP MySQLi 참조