분류
php
MySQLi를 이용한 다중 쿼리
본문
코드 :
$mysqli = new mysqli("db_host", "db_user", "db_pass","db_name", 3306);
$queries = "SELECT * FROM mytable; SELECT * FROM anothertable";
if(mysqli_multi_query($mysqli, $queries)) {
do {
if($result = mysqli_store_result($mysqli)) {
while($row = mysqli_fetch_row($result)) {
foreach($row as $key => $value) {
echo "$key => $value";
}
}
mysqli_free_result($result);
}
if(mysqli_more_results($mysqli)) {
echo "Next result set";
}
} while(mysqli_next_result($mysqli));
}
mysqli_close($mysqli);
- 이전글MySQLi에서의 매개 변수 바인딩 18.01.15
- 다음글직원 테이블 업데이트하기 18.01.15