pg_result_status
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
pg_result_status — 쿼리 결과의 상태 가져오기
설명
pg_result_status(PgSql\Result $result
, int $mode
= PGSQL_STATUS_LONG
): string|int
pg_result_status()는 PgSql\Result 인스턴스의 상태 또는 결과와 관련된 PostgreSQL 명령 완료 태그를 반환합니다.
매개변수
result
- pg_query(), pg_query_params() 또는 pg_execute()(특히)에 의해 반환된 PgSql\Result 인스턴스.
mode
PGSQL_STATUS_LONG
은result
의 숫자 상태를 반환하거나PGSQL_STATUS_STRING
은result
의 명령 태그를 반환합니다. 지정하지 않으면PGSQL_STATUS_LONG
이 기본값입니다.
반환 값
가능한 반환 값은 PGSQL_STATUS_LONG
이 지정된 경우 PGSQL_EMPTY_QUERY
, PGSQL_COMMAND_OK
, PGSQL_TUPLES_OK
, PGSQL_COPY_OUT
, PGSQL_COPY_IN
, PGSQL_BAD_RESPONSE
, PGSQL_NONFATAL_ERROR
및 PGSQL_FATAL_ERROR
입니다. 그렇지 않으면 PostgreSQL 명령 태그가 포함된 문자열이 반환됩니다.
변경 로그
버전 | 설명 |
---|---|
8.1.0 | result 매개변수는 이제 PgSql\Result 인스턴스를 예상합니다. 이전에는 resource가 필요했습니다. |
Examples
예제 #1 pg_result_status() 예제
<?php
// Connect to the database
$conn = pg_pconnect("dbname=publisher");
// Execute a COPY
$result = pg_query($conn, "COPY authors FROM STDIN;");
// Get the result status
$status = pg_result_status($result);
// Determine status
if ($status == PGSQL_COPY_IN)
echo "Copy began.";
else
echo "Copy failed.";
?>
위의 예는 다음을 출력합니다.
Copy began.
기타
- pg_connection_status() - 연결 상태 가져오기