mysqli_stmt::$error_list
(PHP 5 >= 5.4.0, PHP 7, PHP 8)
mysqli_stmt::$error_list -- mysqli_stmt_error_list — 마지막으로 실행된 명령문의 오류 목록을 반환합니다.
설명
객체 지향 스타일
array $mysqli_stmt->error_list;
절차적 스타일
mysqli_stmt_error_list(mysqli_stmt $statement
): array
성공하거나 실패할 수 있는 가장 최근에 호출된 명령문 함수에 대한 오류 배열을 반환합니다.
매개변수
statement
- 절차적 스타일 전용: mysqli_stmt_init()에 의해 반환된 mysqli_stmt 객체.
반환 값
각각 errno, error 및 sqlstate를 포함하는 연관 배열인 오류 목록입니다.
Examples
예제 #1 객체 지향 스타일
<?php
/* Open a connection */
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("CREATE TABLE myCountry LIKE Country");
$mysqli->query("INSERT INTO myCountry SELECT * FROM Country");
$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
if ($stmt = $mysqli->prepare($query)) {
/* drop table */
$mysqli->query("DROP TABLE myCountry");
/* execute query */
$stmt->execute();
echo "Error:\n";
print_r($stmt->error_list);
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
예제 #2 절차적 스타일
<?php
/* Open a connection */
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_query($link, "CREATE TABLE myCountry LIKE Country");
mysqli_query($link, "INSERT INTO myCountry SELECT * FROM Country");
$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
if ($stmt = mysqli_prepare($link, $query)) {
/* drop table */
mysqli_query($link, "DROP TABLE myCountry");
/* execute query */
mysqli_stmt_execute($stmt);
echo "Error:\n";
print_r(mysql_stmt_error_list($stmt));
/* close statement */
mysqli_stmt_close($stmt);
}
/* close connection */
mysqli_close($link);
?>
위의 예는 다음을 출력합니다.
Array ( [0] => Array ( [errno] => 1146 [sqlstate] => 42S02 [error] => Table 'world.myCountry' doesn't exist ) )
기타
- mysqli_stmt_error() - 마지막 문 오류에 대한 문자열 설명을 반환합니다.
- mysqli_stmt_errno() - 가장 최근의 명령문 호출에 대한 오류 코드를 반환합니다.
- mysqli_stmt_sqlstate() - 이전 명령문 작업에서 SQLSTATE 오류를 반환합니다.