DatabaseInfo Class Reference

Inheritance diagram for DatabaseInfo:

MSSQLDatabaseInfo MySQLDatabaseInfo MySQLiDatabaseInfo OCI8DatabaseInfo ODBCDatabaseInfo PgSQLDatabaseInfo SQLiteDatabaseInfo

List of all members.

Public Member Functions

 __construct (Connection $conn, $vendorInfo=array())
 getName ()
 Get name of database.
 __sleep ()
 This method is invoked upon serialize().
 __wakeup ()
 This method is invoked upon unserialize().
 getConnection ()
 Returns Connection being used.
 getTable ($name)
 Get the TableInfo object for specified table name.
 hasTable ($name)
 Return whether database contains specified table.
 getTables ()
 Gets array of TableInfo objects.
 addTable (TableInfo $table)
 Adds a table to this db.
 isSequence ($key)
 getSequences ()
 Gets array of ? objects.
 getVendorSpecificInfo ()
 Get vendor specific optional information for this primary key.

Protected Member Functions

 initTables ()
 initSequences ()

Protected Attributes

 $tables = array()
 $sequences = array()
 $tablesLoaded = false
 have tables been loaded
 $seqsLoaded = false
 have sequences been loaded
 $conn
 $dbname
 Database name.
 $dblink

Private Attributes

 $vendorSpecificInfo = array()
 additional vendor specific information


Detailed Description

Definition at line 30 of file DatabaseInfo.php.


Constructor & Destructor Documentation

DatabaseInfo::__construct ( Connection conn,
vendorInfo = array() 
)

Parameters:
Connection $dbh

Definition at line 63 of file DatabaseInfo.php.

References Connection::getDSN(), and Connection::getResource().

00064     {
00065         $this->conn = $conn;
00066         $this->dblink = $conn->getResource();
00067         $dsn = $conn->getDSN();
00068         $this->dbname = $dsn['database'];
00069         $this->vendorSpecificInfo = $vendorInfo;
00070     }


Member Function Documentation

DatabaseInfo::__sleep (  ) 

This method is invoked upon serialize().

Because the Info class hierarchy is recursive, we must handle the serialization and unserialization of this object.

Returns:
array The class variables that should be serialized (all must be public!).

Definition at line 87 of file DatabaseInfo.php.

00088     {
00089         return array('tables','sequences','conn');
00090     }

DatabaseInfo::__wakeup (  ) 

This method is invoked upon unserialize().

This method re-hydrates the object and restores the recursive hierarchy.

Definition at line 96 of file DatabaseInfo.php.

00097     {
00098         // Re-init vars from serialized connection
00099         $this->dbname = $conn->database;
00100         $this->dblink = $conn->connection;
00101 
00102         // restore chaining
00103         foreach($this->tables as $tbl) {
00104             $tbl->database = $this;
00105             $tbl->dbname = $this->dbname;
00106             $tbl->dblink = $this->dblink;
00107             $tbl->schema = $this->schema;
00108         }
00109     }

DatabaseInfo::addTable ( TableInfo table  ) 

Adds a table to this db.

Table name is case-insensitive.

Parameters:
TableInfo $table

Definition at line 160 of file DatabaseInfo.php.

References TableInfo::getName().

00161     {
00162         $this->tables[strtoupper($table->getName())] = $table;
00163     }

DatabaseInfo::getConnection (  ) 

Returns Connection being used.

Returns:
Connection

Definition at line 115 of file DatabaseInfo.php.

Referenced by TableInfo::__construct().

00116     {
00117         return $this->conn;
00118     }

DatabaseInfo::getName (  ) 

Get name of database.

Returns:
string

Definition at line 76 of file DatabaseInfo.php.

Referenced by TableInfo::__construct().

00077     {
00078         return $this->dbname;
00079     }

DatabaseInfo::getSequences (  ) 

Gets array of ? objects.

Returns:
array ?[]

Definition at line 191 of file DatabaseInfo.php.

References initSequences().

00192     {
00193         if(!$this->seqsLoaded) $this->initSequences();
00194         return array_values($this->sequences); //re-key [numerically]
00195     }

DatabaseInfo::getTable ( name  ) 

Get the TableInfo object for specified table name.

Parameters:
string $name The name of the table to retrieve.
Returns:
TableInfo
Exceptions:
SQLException - if table does not exist in this db.

Definition at line 126 of file DatabaseInfo.php.

References initTables().

00127     {
00128         if(!$this->tablesLoaded) $this->initTables();
00129         if (!isset($this->tables[strtoupper($name)])) {
00130             throw new SQLException("Database `".$this->dbname."` has no table `".$name."`");
00131         }
00132         return $this->tables[ strtoupper($name) ];
00133     }

DatabaseInfo::getTables (  ) 

Gets array of TableInfo objects.

Returns:
array TableInfo[]

Definition at line 149 of file DatabaseInfo.php.

References initTables().

00150     {
00151         if(!$this->tablesLoaded) $this->initTables();
00152         return array_values($this->tables); //re-key [numerically]
00153     }

DatabaseInfo::getVendorSpecificInfo (  ) 

Get vendor specific optional information for this primary key.

Returns:
array vendorSpecificInfo[]

Definition at line 201 of file DatabaseInfo.php.

00202     {
00203         return $this->vendorSpecificInfo;
00204     }

DatabaseInfo::hasTable ( name  ) 

Return whether database contains specified table.

Parameters:
string $name The table name.
Returns:
boolean

Definition at line 140 of file DatabaseInfo.php.

00141   {
00142     return isset($this->tables[strtoupper($name)]);
00143   }

DatabaseInfo::initSequences (  )  [abstract, protected]

DatabaseInfo::initTables (  )  [abstract, protected]

DatabaseInfo::isSequence ( key  ) 

Returns:
boolean
Exceptions:
SQLException 

Definition at line 181 of file DatabaseInfo.php.

References initSequences().

00182     {
00183         if(!$this->seqsLoaded) $this->initSequences();
00184         return isset($this->sequences[ strtoupper($key) ]);
00185     }


Member Data Documentation

DatabaseInfo::$conn [protected]

Definition at line 49 of file DatabaseInfo.php.

DatabaseInfo::$dblink [protected]

Definition at line 58 of file DatabaseInfo.php.

DatabaseInfo::$dbname [protected]

Database name.

Definition at line 52 of file DatabaseInfo.php.

DatabaseInfo::$seqsLoaded = false [protected]

have sequences been loaded

Definition at line 40 of file DatabaseInfo.php.

DatabaseInfo::$sequences = array() [protected]

Definition at line 34 of file DatabaseInfo.php.

DatabaseInfo::$tables = array() [protected]

Definition at line 32 of file DatabaseInfo.php.

DatabaseInfo::$tablesLoaded = false [protected]

have tables been loaded

Definition at line 37 of file DatabaseInfo.php.

DatabaseInfo::$vendorSpecificInfo = array() [private]

additional vendor specific information

Definition at line 43 of file DatabaseInfo.php.


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

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