<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>Kjel is right!

Have a look at Paul's class...Very interesting wrapper

For my personal work, I use it a lot...Thanks Paul :-)

You need adding this code Paul's code:

function postgis($h_host, $h_port, $h_user, $h_password, $h_dbname)
{
    $this->host = $h_host;
    $this->port = $h_port;
    $this->user = $h_user;  
    $this->password = $h_password;   
    $this->dbname = $h_dbname; 
}

function IsAPostGISDataBase($dbname)
{
        $this->connect($dbname);
    $query = "SELECT COUNT(*)>0 AS present FROM pg_proc WHERE proname='postgis_full_version'::text";
    $rec = $this->exec($query);
    if($rec != 0)
    {
          $this->nextRow();  
          $arr = $this->farray(); 
          return $arr;
    }
    else
    {
        return $this->errorMsg();
    }
    $this->close();
  
}

Here is an example about using it in order to have:

- 1)PostgreSQL DB with PostGIS fuctions
- 2) PostgreSQL DB wihout  PostGIS functions: 

Screenshot available at <a class="moz-txt-link-freetext" href="http://techer.pascal.free.fr/postgis/Capture-1.png">http://techer.pascal.free.fr/postgis/Capture-1.png</a>

==========================================================================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>    <head>
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="expires" content="0">       <meta http-equiv="content-type" content="text/html;charset=UTF-8">    
        <link href="./configuration/main.css" rel="stylesheet" type="text/css">
        
        </head>
<BODY>
<table width=90%><tr><td align="left">
<fieldset><legend><font class='titre'>Informations Générales</font></legend>
<?php
// Inclusion de la class de Paul Scott: PostGIS Wrapper Php
include("./postgis_class_inc.php");
include("./getconf.php");

$Connexion = new postgis($conf_host,$conf_port,$conf_user,$conf_passwd,$conf_dbname);
//
// Ouverture de la connexion
//
 $Connexion->connect($Connexion->dbname);// Création d'in objet PostgreSQL
 // Ouverture d'une connexion
 //
 // ---> Requête pour lister les bases présentes
 //
/*
    Quelques informatios d'ordre générale:
     - version de php utilisé
     - version de postgresql
     - version de postgis
     - version de geos
     - version de proj

*/ 
function SendInfo($OnLeft,$OnRight)
{
                echo "<div class='postwrapper'>
                              <div class='posttopbar'>
                                     <div class='postname'>".$OnLeft."</div>
                                     <div class='postdate'>".$OnRight."</div>
               </div>
             </div>";
}


function SendInfoWithText($OnLeft,$OnRight,$Texte)
{
                echo "<div class='postwrapper'>
                                <div class='posttopbar'>
                                       <div class='postname'>".$OnLeft."</div>
                                       <div class='postdate'>".$OnRight."</div>
                 </div>
                  <div class='postcontent'>".$Texte."</div>
               </div>";
}

        $Connexion->exec("SHOW server_version");
        $Connexion->nextRow();  
        $arr = $Connexion->farray();  
        $PG_VERSION = $arr[0];
        $Connexion->exec("SHOW data_directory");
        $Connexion->nextRow();  
        $arr = $Connexion->farray();  
        $PG_DATA= $arr[0];
        
SendInfoWithText("<b>Informations générales</b>",
                        "Informations PostgreSQL",
         "PostgreSQL: Version = ".$PG_VERSION."<br>
           PostgreSQL: PGDATA  = ".$PG_DATA."<br>");  


  $Connexion->exec("SELECT pg_database.datname as Database FROM pg_database, pg_user
     WHERE pg_database.datdba = pg_user.usesysid and pg_database.datname not
     like 'template%' order by datname");   
   $Connexion->setRow(-1);
   $Listing_DB = array();
   $Listing_PostGIS_DB = array();
   $Check_Img_DB = array();
 if ( $Connexion->numRows() )
  {while ($Connexion->nextRow()) 
    { // Début de la boucle while
         $rs = $Connexion->fobject(); 
         
         $pg = new postgis($conf_host,$conf_port,$conf_user,$conf_passwd,$rs->database);
         
         $r = array($pg->IsAPostGISDataBase($pg->dbname));
         $Listing_DB[] = $rs->database;
       
        if ($r[0][0]=='t')
        {
           $Check_Img_DB[] = "<img src='./img/ok.png'/>";
           $Listing_PostGIS_DB[] = $rs->database;
        }
        else
        {
           $Check_Img_DB[] = "<img src='./img/delete.png'/>";
        }
     }// Fin de la boucle while!
     if (count($Listing_PostGIS_DB))// Il y a au moins une base PostGIS
     {
       $pg = new postgis($conf_host,$conf_port,$conf_user,$conf_passwd,$Listing_PostGIS_DB[0]);
       $pg->connect($Listing_PostGIS_DB[0]);
       $pg->exec("SELECT postgis_lib_version(),postgis_geos_version(),postgis_proj_version()");
       $pg->setRow(-1);
       $pg->nextRow(); 
       $rs = $pg->fobject(); 
       $Texte_Info_PostGIS =  "PostGIS: Version = ".$rs->postgis_lib_version."<br>
                               Geos: Version  = ".$rs->postgis_geos_version."<br>
                               Proj: Version  = ".$rs->postgis_proj_version;
     }
     else
     {
       $Texte_Info_PostGIS = "<b>Aucune base PostGIS trouvée</b>";
     }
     
SendInfoWithText("<b>Informations générales</b>",
                                "Informations PostGIS",
                 $Texte_Info_PostGIS
                 ); 
                 
     for($IntDB=0;$IntDB<count($Listing_DB);$IntDB++)
     {
        SendInfo("<b>".intval($IntDB+1)." - base = ".$Listing_DB[$IntDB]."</b>",
                                         $Check_Img_DB[$IntDB]
                         );
     }
    
  }
  else // Oh! Aucune base trouvée!
  {echo "Oups!...Apparement aucune base n'a été trouvée à part les bases habituelles
         template0 et template1. Il se peut aussi que votre serveur PostgreSQL soit pas actif ou mauvaise
          connection";}


$Connexion->close();
?>
</fieldset>
</td>
</tr>
</table>
</body></html>

==========================================================================================================================

</pre>
<pre class="moz-signature" cols="72">--david;
-------------------------------------------------
Jean David TECHER
e-mail: davidtecher(at)yahoo(dot)fr
sites: <a class="moz-txt-link-freetext" href="http://www.postgis.fr">http://www.postgis.fr</a>
       <a class="moz-txt-link-freetext" href="http://techer.pascal.free.fr/postgis/">http://techer.pascal.free.fr/postgis/</a>
-------------------------------------------------
</pre>
<br>
<br>
Abe Gillespie a écrit :
<blockquote
 cite="mida6d397e30510031018o3f939ec3h23705d6540a9ce30@mail.gmail.com"
 type="cite">
  <pre wrap="">Hi Kjel,

You might want to try this project:

<a class="moz-txt-link-freetext" href="http://avoir.uwc.ac.za/projects/postgis/">http://avoir.uwc.ac.za/projects/postgis/</a>

At the very least you can look at the class's code and see how it does
things with PostGIS.

-Abe

On 10/3/05, Kjel Anderson <a class="moz-txt-link-rfc2396E" href="mailto:kanderson@maponics.com"><kanderson@maponics.com></a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hello list,

I am just getting started using PostGIS. I need to find some good working PHP
examples. I am trying to figure out how to take an array of raw geometry and
turn it into an envelope. I have read the documentation, but I find it a bit
sparse. Any help appreciated,

Thanks,
Kjel
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>

  </pre>
</blockquote>
</body>
</html>