PgSQLDatabaseInfo Class Reference

Inheritance diagram for PgSQLDatabaseInfo:

DatabaseInfo

List of all members.

Protected Member Functions

 initTables ()
 initSequences ()
 PgSQL sequences.


Detailed Description

Definition at line 31 of file PgSQLDatabaseInfo.php.


Member Function Documentation

PgSQLDatabaseInfo::initSequences (  )  [protected]

PgSQL sequences.

Returns:
void
Exceptions:
SQLException 

Reimplemented from DatabaseInfo.

Definition at line 84 of file PgSQLDatabaseInfo.php.

References $result.

00085     {
00086      
00087     $this->sequences = array();
00088        
00089         $result = pg_query($this->conn->getResource(), "SELECT c.oid, 
00090                             case when n.nspname='public' then c.relname else n.nspname||'.'||c.relname end as relname 
00091                             FROM pg_class c join pg_namespace n on (c.relnamespace=n.oid)
00092                             WHERE c.relkind = 'S'
00093                               AND n.nspname NOT IN ('information_schema','pg_catalog')
00094                               AND n.nspname NOT LIKE 'pg_temp%'
00095                               AND n.nspname NOT LIKE 'pg_toast%'
00096                             ORDER BY name");
00097                             
00098         if (!$result) {
00099             throw new SQLException("Could not list sequences", pg_last_error($this->dblink));
00100         }
00101     
00102     while ($row = pg_fetch_assoc($result)) {
00103       // FIXME -- decide what info we need for sequences & then create a SequenceInfo object (if needed)
00104       $obj = new stdClass;
00105       $obj->name = $row['relname'];
00106       $obj->oid = $row['oid'];
00107             $this->sequences[strtoupper($row['relname'])] = $obj;
00108         }
00109     
00110     }

PgSQLDatabaseInfo::initTables (  )  [protected]

Exceptions:
SQLException 
Returns:
void

Reimplemented from DatabaseInfo.

Definition at line 37 of file PgSQLDatabaseInfo.php.

References $result.

00038     {
00039         include_once 'creole/drivers/pgsql/metadata/PgSQLTableInfo.php';
00040         
00041         // Get Database Version
00042   // TODO: www.php.net/pg_version
00043         $result = pg_query ($this->conn->getResource(), "SELECT version() as ver");
00044         
00045         if (!$result)
00046         {
00047           throw new SQLException ("Failed to select database version");
00048         } // if (!$result)
00049         $row = pg_fetch_assoc ($result, 0);
00050         $arrVersion = sscanf ($row['ver'], '%*s %d.%d');
00051         $version = sprintf ("%d.%d", $arrVersion[0], $arrVersion[1]);
00052         // Clean up
00053         $arrVersion = null;
00054         $row = null;
00055         pg_free_result ($result);
00056         $result = null;
00057 
00058         $result = pg_query($this->conn->getResource(), "SELECT c.oid, 
00059                             case when n.nspname='public' then c.relname else n.nspname||'.'||c.relname end as relname 
00060                             FROM pg_class c join pg_namespace n on (c.relnamespace=n.oid)
00061                             WHERE c.relkind = 'r'
00062                               AND n.nspname NOT IN ('information_schema','pg_catalog')
00063                               AND n.nspname NOT LIKE 'pg_temp%'
00064                               AND n.nspname NOT LIKE 'pg_toast%'
00065                             ORDER BY relname");
00066 
00067         if (!$result) {
00068             throw new SQLException("Could not list tables", pg_last_error($this->dblink));
00069         }
00070 
00071         while ($row = pg_fetch_assoc($result)) {
00072             $this->tables[strtoupper($row['relname'])] = new PgSQLTableInfo($this, $row['relname'], $version, $row['oid']);
00073         }
00074     
00075     $this->tablesLoaded = true;
00076     }


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:10:50 2009 for fareofficelib by  doxygen 1.5.8