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
Printable View
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
echo connection_status();
will tell you the connection state.
and what is this
define('DB_DSN', 'pgsql://phptest:[email protected]/phptest');
all you did was assign a variable that equals
'pgsql://phptest:[email protected]/phptest'
how is that helping?
yes, I defined a variable that holds my connectionString to the database. It's like assigning the Application("ConnectionString") in a global.asa in asp.
that way all I have to do is
PHP Code:// connects to database
$db = DB::connect(DB_DSN);
// querys the database
$getRecords = $db->query('SELECT * FROM tablename');
// closes connection
$db->disconnect();