pg_last_error
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
pg_last_error — 연결의 마지막 오류 메시지 문자열을 가져옵니다.
설명
pg_last_error(PgSql\Connection $connection
= null
): string
pg_last_error()는 주어진 connection
에 대한 마지막 오류 메시지를 반환합니다.
오류 메시지는 내부 PostgreSQL(libpq) 함수 호출로 덮어쓸 수 있습니다. PostgreSQL 모듈 함수 내에서 여러 오류가 발생하면 적절한 오류 메시지를 반환하지 않을 수 있습니다.
더 나은 오류 처리를 위해 pg_result_error(), pg_result_error_field(), pg_result_status() 및 pg_connection_status()를 사용하십시오.
메모: 이 함수는 pg_errormessage()라고 불렸습니다.
매개변수
connection
- PgSql\Connection 인스턴스.
connection
을 지정하지 않으면 기본 연결이 사용됩니다. 기본 연결은 pg_connect() 또는 pg_pconnect()에 의해 만들어진 마지막 연결입니다.
반환 값
지정된 connection
의 마지막 오류 메시지가 포함된 문자열입니다.
변경 로그
버전 | 설명 |
---|---|
8.1.0 | connection 매개변수는 이제 PgSql\Connection 인스턴스를 필요로 합니다. 이전에는 resource가 필요했습니다. |
8.0.0 | connection 은 이제 nullable입니다. |
Examples
예제 #1 pg_last_error() 예제
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
// Query that fails
$res = pg_query($dbconn, "select * from doesnotexist");
echo pg_last_error($dbconn);
?>
기타
- pg_result_error() - 결과와 관련된 오류 메시지 가져오기
- pg_result_error_field() - 오류 보고서의 개별 필드를 반환합니다.