mysqli::$errno

(PHP 5, PHP 7, PHP 8)

mysqli::$errno -- mysqli_errno — 가장 최근의 함수 호출에 대한 오류 코드를 반환합니다.


설명

객체 지향 스타일

int $mysqli->errno;

절차적 스타일

mysqli_errno(mysqli $mysql): int

성공하거나 실패할 수 있는 가장 최근의 MySQLi 함수 호출에 대한 마지막 오류 코드를 반환합니다.


매개변수

mysql
절차적 스타일 전용: mysqli_connect() 또는 mysqli_init()에 의해 반환된 mysqli 객체

반환 값

실패한 경우 마지막 호출에 대한 오류 코드 값입니다. 0은 오류가 발생하지 않았음을 의미합니다.


Examples

예제 #1 $mysqli->errno 예제

객체 지향 스타일

                  
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}

if (!$mysqli->query("SET a=1")) {
    printf("Errorcode: %d\n", $mysqli->errno);
}

/* close connection */
$mysqli->close();
?>
                  
                

절차적 스타일

                  
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

if (!mysqli_query($link, "SET a=1")) {
    printf("Errorcode: %d\n", mysqli_errno($link));
}

/* close connection */
mysqli_close($link);
?>
                  
                

위의 예는 다음을 출력합니다.

Errorcode: 1193
                

기타