Results 1 to 3 of 3

Thread: Check DB connection state

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Check DB connection state

    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'); 
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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?

  3. #3

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    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(); 
    Last edited by Memnoch1207; Apr 9th, 2003 at 03:01 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width