TableInfo Class Reference

Inheritance diagram for TableInfo:

MSSQLTableInfo MySQLiTableInfo MySQLTableInfo OCI8TableInfo ODBCTableInfo PgSQLTableInfo SQLiteTableInfo

List of all members.

Public Member Functions

 __construct (DatabaseInfo $database, $name)
 __sleep ()
 This "magic" method is invoked upon serialize().
 __wakeup ()
 This "magic" method is invoked upon unserialize().
 getPrimaryKey ()
 Get parimary key in this table.
 getColumn ($name)
 Get the ColumnInfo object for specified column.
 hasColumn ($name)
 Return whether table contains specified column.
 getColumns ()
 Get array of columns for this table.
 getForeignKey ($name)
 Get specified fk for this table.
 getForeignKeys ()
 Get all foreign keys.
 getIndex ($name)
 Gets the IndexInfo object for a specified index.
 getIndexes ()
 Get array of IndexInfo objects for this table.
 getIndices ()
 Alias for getIndexes() method.
 getName ()
 Get table name.
 toString ()
 foreignKeysLoaded ()
 Have foreign keys been loaded?
 primaryKeyLoaded ()
 Has primary key info been loaded?
 columnsLoaded ()
 Have columns been loaded?
 indexesLoaded ()
 Has index information been loaded?
 getVendorSpecificInfo ()
 Get vendor specific optional information for this table.
 addColumn (ColumnInfo $column)
 Adds a column to this table.
 getDatabase ()
 Get the parent DatabaseInfo object.

Protected Member Functions

 initColumns ()
 Loads the columns.
 initPrimaryKey ()
 Loads the primary key information for this table.
 initForeignKeys ()
 Loads the foreign keys for this table.
 initIndexes ()
 Loads the indexes information for this table.
 initVendorSpecificInfo ()
 Loads the vendor specific information for this table.

Protected Attributes

 $name
 $columns = array()
 $foreignKeys = array()
 $indexes = array()
 $primaryKey
 $pkLoaded = false
 $fksLoaded = false
 $indexesLoaded = false
 $colsLoaded = false
 $vendorLoaded = false
 $vendorSpecificInfo = array()
 $conn
 $database
 $dblink
 Shortcut to db resource link id (needed by drivers for queries).
 $dbname
 Shortcut to db name (needed by many drivers for queries).


Detailed Description

Definition at line 30 of file TableInfo.php.


Constructor & Destructor Documentation

TableInfo::__construct ( DatabaseInfo database,
name 
)

Parameters:
string $table The table name.
string $database The database name.
resource $dblink The db connection resource.

Definition at line 73 of file TableInfo.php.

References $name, DatabaseInfo::getConnection(), and DatabaseInfo::getName().

00073                                                         {
00074         $this->database = $database;
00075         $this->name = $name;
00076         $this->conn = $database->getConnection(); // shortcut because all drivers need this for the queries
00077         $this->dblink = $this->conn->getResource();
00078         $this->dbname = $database->getName();
00079     }


Member Function Documentation

TableInfo::__sleep (  ) 

This "magic" 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 TableInfo.php.

00088     {
00089         return array('name', 'columns', 'foreignKeys', 'indexes', 'primaryKey');
00090     }

TableInfo::__wakeup (  ) 

This "magic" method is invoked upon unserialize().

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

Definition at line 96 of file TableInfo.php.

00097     {
00098         // restore chaining
00099         foreach($this->columns as $col) {
00100             $col->table = $this;
00101         }
00102     }

TableInfo::addColumn ( ColumnInfo column  ) 

Adds a column to this table.

Definition at line 295 of file TableInfo.php.

References ColumnInfo::getName().

00296     {
00297         $this->columns[$column->getName()] = $column;
00298     }

TableInfo::columnsLoaded (  ) 

Have columns been loaded?

Definition at line 273 of file TableInfo.php.

00274     {
00275         return $this->colsLoaded;
00276     }

TableInfo::foreignKeysLoaded (  ) 

Have foreign keys been loaded?

Definition at line 261 of file TableInfo.php.

00262     {
00263         return $this->fksLoaded;
00264     }

TableInfo::getColumn ( name  ) 

Get the ColumnInfo object for specified column.

Parameters:
string $name The column name.
Returns:
ColumnInfo
Exceptions:
SQLException - if column does not exist for this table.

Definition at line 154 of file TableInfo.php.

References $name, and initColumns().

00155     {
00156         if(!$this->colsLoaded) $this->initColumns();
00157         if (!isset($this->columns[$name])) {
00158             throw new SQLException("Table `".$this->name."` has no column `".$name."`");
00159         }
00160         return $this->columns[$name];
00161     }

TableInfo::getColumns (  ) 

Get array of columns for this table.

Returns:
array ColumnInfo[]

Definition at line 178 of file TableInfo.php.

References initColumns().

00179     {
00180         if(!$this->colsLoaded) $this->initColumns();
00181         return array_values($this->columns); // re-key numerically
00182     }

TableInfo::getDatabase (  ) 

Get the parent DatabaseInfo object.

Definition at line 301 of file TableInfo.php.

00302     {
00303         return $this->database;
00304     }

TableInfo::getForeignKey ( name  ) 

Get specified fk for this table.

Parameters:
string $name The foreign key name to retrieve.
Returns:
ForeignKeyInfo
Exceptions:
SQLException - if fkey does not exist for this table.

Definition at line 190 of file TableInfo.php.

References $name, and initForeignKeys().

00191     {
00192         if(!$this->fksLoaded) $this->initForeignKeys();
00193         if (!isset($this->foreignKeys[$name])) {
00194             throw new SQLException("Table `".$this->name."` has no foreign key `".$name."`");
00195         }
00196         return $this->foreignKeys[$name];
00197     }

TableInfo::getForeignKeys (  ) 

Get all foreign keys.

Returns:
array ForeignKeyInfo[]

Definition at line 203 of file TableInfo.php.

References initForeignKeys().

00204     {
00205         if(!$this->fksLoaded) $this->initForeignKeys();
00206         return array_values($this->foreignKeys);
00207     }

TableInfo::getIndex ( name  ) 

Gets the IndexInfo object for a specified index.

Parameters:
string $name The index name to retrieve.
Returns:
IndexInfo
Exceptions:
SQLException - if index does not exist for this table.

Definition at line 215 of file TableInfo.php.

References $name, indexesLoaded(), and initIndexes().

00216     {
00217         if(!$this->indexesLoaded) $this->initIndexes();
00218         if (!isset($this->indexes[$name])) {
00219             throw new SQLException("Table `".$this->name."` has no index `".$name."`");
00220         }
00221         return $this->indexes[$name];
00222     }

TableInfo::getIndexes (  ) 

Get array of IndexInfo objects for this table.

Returns:
array IndexInfo[]

Definition at line 228 of file TableInfo.php.

References indexesLoaded(), and initIndexes().

Referenced by getIndices().

00229     {
00230         if(!$this->indexesLoaded) $this->initIndexes();
00231         return array_values($this->indexes);
00232     }

TableInfo::getIndices (  ) 

Alias for getIndexes() method.

Returns:
array

Definition at line 238 of file TableInfo.php.

References getIndexes().

00239     {
00240         return $this->getIndexes();
00241     }

TableInfo::getName (  ) 

Get table name.

Returns:
string

Definition at line 247 of file TableInfo.php.

Referenced by DatabaseInfo::addTable().

00248     {
00249         return $this->name;
00250     }

TableInfo::getPrimaryKey (  ) 

Get parimary key in this table.

Exceptions:
Exception - if foreign keys are unsupported by DB.
Returns:
array ForeignKeyInfo[]

Definition at line 142 of file TableInfo.php.

References initPrimaryKey().

00143     {
00144         if(!$this->pkLoaded) $this->initPrimaryKey();
00145         return $this->primaryKey;
00146     }

TableInfo::getVendorSpecificInfo (  ) 

Get vendor specific optional information for this table.

Returns:
array vendorSpecificInfo[]

Definition at line 288 of file TableInfo.php.

References initVendorSpecificInfo().

00289     {
00290         if(!$this->vendorLoaded) $this->initVendorSpecificInfo();
00291         return $this->vendorSpecificInfo;
00292     }

TableInfo::hasColumn ( name  ) 

Return whether table contains specified column.

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

Definition at line 168 of file TableInfo.php.

References $name, and initColumns().

00169     {
00170         if(!$this->colsLoaded) $this->initColumns();
00171         return isset($this->columns[$name]);
00172     }

TableInfo::indexesLoaded (  ) 

TableInfo::initColumns (  )  [abstract, protected]

Loads the columns.

Returns:
void

Reimplemented in MSSQLTableInfo, MySQLTableInfo, MySQLiTableInfo, ODBCTableInfo, OCI8TableInfo, PgSQLTableInfo, and SQLiteTableInfo.

Referenced by getColumn(), getColumns(), and hasColumn().

TableInfo::initForeignKeys (  )  [abstract, protected]

Loads the foreign keys for this table.

Returns:
void

Reimplemented in MSSQLTableInfo, MySQLTableInfo, MySQLiTableInfo, ODBCTableInfo, OCI8TableInfo, PgSQLTableInfo, and SQLiteTableInfo.

Referenced by getForeignKey(), and getForeignKeys().

TableInfo::initIndexes (  )  [abstract, protected]

Loads the indexes information for this table.

Returns:
void

Reimplemented in MSSQLTableInfo, MySQLTableInfo, MySQLiTableInfo, ODBCTableInfo, OCI8TableInfo, PgSQLTableInfo, and SQLiteTableInfo.

Referenced by getIndex(), and getIndexes().

TableInfo::initPrimaryKey (  )  [abstract, protected]

Loads the primary key information for this table.

Returns:
void

Reimplemented in MSSQLTableInfo, MySQLTableInfo, MySQLiTableInfo, ODBCTableInfo, OCI8TableInfo, PgSQLTableInfo, and SQLiteTableInfo.

Referenced by getPrimaryKey().

TableInfo::initVendorSpecificInfo (  )  [protected]

Loads the vendor specific information for this table.

Returns:
void

Reimplemented in MySQLTableInfo.

Definition at line 135 of file TableInfo.php.

Referenced by getVendorSpecificInfo().

00135 {}

TableInfo::primaryKeyLoaded (  ) 

Has primary key info been loaded?

Definition at line 267 of file TableInfo.php.

00268     {
00269         return $this->pkLoaded;
00270     }

TableInfo::toString (  ) 

Returns:
string

Definition at line 255 of file TableInfo.php.

00256     {
00257         return $this->name;
00258     }


Member Data Documentation

TableInfo::$colsLoaded = false [protected]

Definition at line 41 of file TableInfo.php.

TableInfo::$columns = array() [protected]

Definition at line 33 of file TableInfo.php.

TableInfo::$conn [protected]

Definition at line 54 of file TableInfo.php.

TableInfo::$database [protected]

Definition at line 60 of file TableInfo.php.

TableInfo::$dblink [protected]

Shortcut to db resource link id (needed by drivers for queries).

Definition at line 63 of file TableInfo.php.

TableInfo::$dbname [protected]

Shortcut to db name (needed by many drivers for queries).

Definition at line 66 of file TableInfo.php.

TableInfo::$fksLoaded = false [protected]

Definition at line 39 of file TableInfo.php.

TableInfo::$foreignKeys = array() [protected]

Definition at line 34 of file TableInfo.php.

TableInfo::$indexes = array() [protected]

Definition at line 35 of file TableInfo.php.

TableInfo::$indexesLoaded = false [protected]

Definition at line 40 of file TableInfo.php.

TableInfo::$name [protected]

TableInfo::$pkLoaded = false [protected]

Definition at line 38 of file TableInfo.php.

TableInfo::$primaryKey [protected]

Definition at line 36 of file TableInfo.php.

TableInfo::$vendorLoaded = false [protected]

Definition at line 42 of file TableInfo.php.

TableInfo::$vendorSpecificInfo = array() [protected]

Definition at line 48 of file TableInfo.php.


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