Skip site navigation (1) Skip section navigation (2)

Retrieve a list of databases using PHP

From: Jerry <admin(at)paransolutions(dot)com(dot)au>
To: pgsql-php(at)postgresql(dot)org
Subject: Retrieve a list of databases using PHP
Date: 2005-04-05 21:13:46
Message-ID: 1112735626.7312.13.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-php
Try 
SELECT datname FROM pg_database

eg:

<?
$db="template1";
$db_connect=pg_connect("host=192.168.101.1 user=postgres port=5432
dbname=$db");
$db_query="SELECT datname FROM pg_database";
$db_result=pg_exec($db_connect, $db_query);
$db_numrows=pg_numrows($db_result);

//display results

for ($i=0; $i<$db_numrows; $i++)
    {
        $pg_data=pg_fetch_row($db_result, $i);
            printf("$pg_data[0]\n");
                }
                ?>

                      admin(at)paransolutions(dot)com(dot)au



pgsql-php by date

Next:From: Arcane_RhinoDate: 2005-04-12 20:08:17
Subject: unsubscribe
Previous:From: Christopher Kings-LynneDate: 2005-04-05 15:25:21
Subject: Re: problem with predefined variables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group