<!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-&gt;host = $h_host;
    $this-&gt;port = $h_port;
    $this-&gt;user = $h_user;  
    $this-&gt;password = $h_password;   
    $this-&gt;dbname = $h_dbname; 
}

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

==========================================================================================================================
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;HTML&gt;        &lt;head&gt;
        &lt;meta http-equiv="Pragma" content="no-cache"&gt;
        &lt;meta http-equiv="expires" content="0"&gt;        &lt;meta http-equiv="content-type" content="text/html;charset=UTF-8"&gt;        
        &lt;link href="./configuration/main.css" rel="stylesheet" type="text/css"&gt;
        
        &lt;/head&gt;
&lt;BODY&gt;
&lt;table width=90%&gt;&lt;tr&gt;&lt;td align="left"&gt;
&lt;fieldset&gt;&lt;legend&gt;&lt;font class='titre'&gt;Informations G&eacute;n&eacute;rales&lt;/font&gt;&lt;/legend&gt;
&lt;?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-&gt;connect($Connexion-&gt;dbname);// Cr&eacute;ation d'in objet PostgreSQL
 // Ouverture d'une connexion
 //
 // ---&gt; Requ&ecirc;te pour lister les bases pr&eacute;sentes
 //
/*
    Quelques informatios d'ordre g&eacute;n&eacute;rale:
     - version de php utilis&eacute;
     - version de postgresql
     - version de postgis
     - version de geos
     - version de proj

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


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

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


  $Connexion-&gt;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-&gt;setRow(-1);
   $Listing_DB = array();
   $Listing_PostGIS_DB = array();
   $Check_Img_DB = array();
 if ( $Connexion-&gt;numRows() )
  {while ($Connexion-&gt;nextRow()) 
    { // D&eacute;but de la boucle while
         $rs = $Connexion-&gt;fobject(); 
         
         $pg = new postgis($conf_host,$conf_port,$conf_user,$conf_passwd,$rs-&gt;database);
         
         $r = array($pg-&gt;IsAPostGISDataBase($pg-&gt;dbname));
         $Listing_DB[] = $rs-&gt;database;
       
        if ($r[0][0]=='t')
        {
           $Check_Img_DB[] = "&lt;img src='./img/ok.png'/&gt;";
           $Listing_PostGIS_DB[] = $rs-&gt;database;
        }
        else
        {
           $Check_Img_DB[] = "&lt;img src='./img/delete.png'/&gt;";
        }
     }// 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-&gt;connect($Listing_PostGIS_DB[0]);
       $pg-&gt;exec("SELECT postgis_lib_version(),postgis_geos_version(),postgis_proj_version()");
       $pg-&gt;setRow(-1);
       $pg-&gt;nextRow(); 
       $rs = $pg-&gt;fobject(); 
       $Texte_Info_PostGIS =  "PostGIS: Version = ".$rs-&gt;postgis_lib_version."&lt;br&gt;
                               Geos: Version  = ".$rs-&gt;postgis_geos_version."&lt;br&gt;
                               Proj: Version  = ".$rs-&gt;postgis_proj_version;
     }
     else
     {
       $Texte_Info_PostGIS = "&lt;b&gt;Aucune base PostGIS trouv&eacute;e&lt;/b&gt;";
     }
     
SendInfoWithText("&lt;b&gt;Informations g&eacute;n&eacute;rales&lt;/b&gt;",
                                  "Informations PostGIS",
                 $Texte_Info_PostGIS
                 ); 
                 
     for($IntDB=0;$IntDB&lt;count($Listing_DB);$IntDB++)
     {
        SendInfo("&lt;b&gt;".intval($IntDB+1)." - base = ".$Listing_DB[$IntDB]."&lt;/b&gt;",
                                           $Check_Img_DB[$IntDB]
                         );
     }
    
  }
  else // Oh! Aucune base trouv&eacute;e!
  {echo "Oups!...Apparement aucune base n'a &eacute;t&eacute; trouv&eacute;e &agrave; part les bases habituelles
         template0 et template1. Il se peut aussi que votre serveur PostgreSQL soit pas actif ou mauvaise
          connection";}


$Connexion-&gt;close();
?&gt;
&lt;/fieldset&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;&lt;/html&gt;

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

</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 &eacute;crit&nbsp;:
<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">&lt;kanderson@maponics.com&gt;</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>