Home > Archive > PHP with PostgreSQL > April 2005 > Retrieve a list of databases using PHP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Retrieve a list of databases using PHP
Jerry

2005-04-05, 7:02 am

Try
SELECT datname FROM pg_database

eg:

<?
$db="template1";
$db_connect=pg_conne
ct("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_numro
ws($db_result);

//display results

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

admin@paransolutions
.com.au




Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com