Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

pg_connection_status

(PHP 4 >= 4.2.0, PHP 5)

pg_connection_status --  Get connection status

Описание

int pg_connection_status ( resource connection )

pg_connection_status() returns the status of the specified connection.

Список параметров

connection

PostgreSQL database connection resource.

Возвращаемые значения

PGSQL_CONNECTION_OK or PGSQL_CONNECTION_BAD.

Примеры

Пример 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';
  }   
?>

Смотрите также

pg_connection_busy()



pg_convert> <pg_connection_reset
Last updated: Sat, 27 Jan 2007
 
add a note add a note User Contributed Notes
pg_connection_status
Mathieu De Zutter
02-Aug-2006 05:45
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
david dot tulloh at infaze dot com dot au
14-Jun-2005 08:33
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';
?>
zytox at hotmail dot com
02-Apr-2005 10:34
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.

pg_convert> <pg_connection_reset
Last updated: Sat, 27 Jan 2007
 
 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571