Does anyone know how I can check the state of the db connection?

In asp it would be something like this
if(conn.state = 1) then
end if

how would this be done in php?

my DB_DSN looks like this

PHP Code:
define('DB_DSN',  'pgsql://phptest:[email protected]/phptest');