PHP.mk документација

pg_connection_status

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.pg-connection-status.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.pg-connection-status.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
pg_connection_status

Референца за `function.pg-connection-status.php` со подобрена типографија и навигација.

function.pg-connection-status.php

pg_connection_status

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

pg_connection_status Добиј статус на конекција

= NULL

pg_connection_status(PgSql\Connection $connection): int

pg_connection_status() го враќа статусот на наведениот connection.

Параметри

connection

Еден PgSql\Connection instance.

Вратени вредности

PGSQL_CONNECTION_OK or PGSQL_CONNECTION_BAD.

Дневник на промени

Верзија = NULL
8.1.0 На connection параметарот очекува PgSql\Connection инстанца сега; претходно, а resource се очекуваше.

Примери

Пример #1 pg_connection_status() example

<?php
$dbconn
= pg_connect("dbname=publisher") or die("Could not connect");
$stat = pg_connection_status($dbconn);
if (
$stat === PGSQL_CONNECTION_OK) {
echo
'Connection status ok';
} else {
echo
'Connection status bad';
}
?>

Види Исто така

Белешки од корисници 4 белешки

Матиу Де Зутер
19 години пред
Being careful with the comparison operators is not enough:

<?php
if (pg_connection_status($link)===PGSQL_CONNECTION_BAD)
   reconnect($link);
?>
 
The reconnect won't be trigged when $link is null.

The manual is just wrong, there are three return values: PGSQL_CONNECTION_OK, PGSQL_CONNECTION_BAD, null
zytox на hotmail точка com
20 години пред
If the connection variable is NULL this function returns 0 in PHP 5.0.2. Havent figured out any more erratic values for the connection variable but be careful.
david точка tulloh на infaze точка com точка au
20 години пред
I think zytox is incorrect, at least in PHP 5.0.4.
It returns null, but you have to be careful with your comparison operators.

As an example:
<?php
unset($null);
if (pg_connection_status($null)===PGSQL_CONNECTION_OK)
    echo 'this is not called';
if (pg_connection_status($null)==PGSQL_CONNECTION_OK)
    echo 'this is called because NULL==0 is true';
?>
Анонимен
пред 7 години
The wiki page doesn't currently reflect that, but if you're passing PGSQL_CONNECT_ASYNC to pg_connect, creating the connection won't block and transitions through extra states expressed by those constants.

PGSQL_CONNECTION_AUTH_OK
PGSQL_CONNECTION_AWAITING_RESPONSE
PGSQL_CONNECTION_MADE
PGSQL_CONNECTION_SETENV
PGSQL_CONNECTION_SSL_STARTUP
PGSQL_CONNECTION_STARTED
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.