ODBCTableInfo Class Reference

Inheritance diagram for ODBCTableInfo:

TableInfo

List of all members.

Protected Member Functions

 initColumns ()
 initPrimaryKey ()
 initIndexes ()
 initForeignKeys ()


Detailed Description

Definition at line 31 of file ODBCTableInfo.php.


Member Function Documentation

ODBCTableInfo::initColumns (  )  [protected]

See also:
TableInfo::initColumns()

Reimplemented from TableInfo.

Definition at line 36 of file ODBCTableInfo.php.

References TableInfo::$name, $result, ODBCTypes::getType(), and ODBCTypes::loadTypeMap().

Referenced by initForeignKeys(), and initPrimaryKey().

00037     {
00038         include_once 'creole/metadata/ColumnInfo.php';
00039         include_once 'creole/drivers/odbc/ODBCTypes.php';
00040 
00041         ODBCTypes::loadTypeMap($this->conn);
00042 
00043         $result = @odbc_columns($this->conn->getResource(), $this->dbname, '', $this->name);
00044 
00045         if (!$result)
00046             throw new SQLException('Could not get column names', $this->conn->nativeError());
00047 
00048         while (odbc_fetch_row($result))
00049         {
00050             $name = odbc_result($result, 'COLUMN_NAME');
00051             $type = odbc_result($result, 'TYPE_NAME');
00052             $length = odbc_result($result, 'LENGTH');
00053             $is_nullable = odbc_result($result, 'NULLABLE');
00054             $default = '';
00055             $precision = odbc_result($result, 'PRECISION');
00056             $scale = odbc_result($result, 'SCALE');
00057             $this->columns[$name] = new ColumnInfo($this, $name, ODBCTypes::getType($type), $type, $length, $precision, $scale, $is_nullable, $default);
00058         }
00059 
00060         @odbc_free_result($result);
00061 
00062         $this->colsLoaded = true;
00063     }

ODBCTableInfo::initForeignKeys (  )  [protected]

See also:
TableInfo::initForeignKeys()

Reimplemented from TableInfo.

Definition at line 103 of file ODBCTableInfo.php.

References TableInfo::$name, $result, and initColumns().

00104     {
00105         // columns have to be loaded first
00106         if (!$this->colsLoaded) $this->initColumns();
00107 
00108         $result = @odbc_foreignkeys($this->conn->getResource(), '', '', '', $this->dbname, '', $this->name);
00109 
00110         while (odbc_fetch_row($result))
00111         {
00112             $name = odbc_result($result, 'COLUMN_NAME');
00113             $ftbl = odbc_result($result, 'FKTABLE_NAME');
00114             $fcol = odbc_result($result, 'FKCOLUMN_NAME');
00115 
00116             if (!isset($this->foreignKeys[$name]))
00117             {
00118                 $this->foreignKeys[$name] = new ForeignKeyInfo($name);
00119 
00120                 if (($foreignTable = $this->database->getTable($ftbl)) === null)
00121                 {
00122                     $foreignTable = new TableInfo($ltbl);
00123                     $this->database->addTable($foreignTable);
00124                 }
00125 
00126                 if (($foreignCol = $foreignTable->getColumn($name)) === null)
00127                 {
00128                     $foreignCol = new ColumnInfo($foreignTable, $name);
00129                     $foreignTable->addColumn($foreignCol);
00130                 }
00131 
00132                 $this->foreignKeys[$name]->addReference($this->columns[$name], $foreignCol);
00133             }
00134         }
00135 
00136         @odbc_free_result($result);
00137 
00138         $this->fksLoaded = true;
00139     }

ODBCTableInfo::initIndexes (  )  [protected]

See also:
TableInfo::initIndexes()

Reimplemented from TableInfo.

Definition at line 95 of file ODBCTableInfo.php.

00096     {
00097         // Not sure if this can be implemented in a driver-independent way.
00098     }

ODBCTableInfo::initPrimaryKey (  )  [protected]

See also:
TableInfo::initPrimaryKey()

Reimplemented from TableInfo.

Definition at line 68 of file ODBCTableInfo.php.

References TableInfo::$name, $result, and initColumns().

00069     {
00070         include_once 'creole/metadata/PrimaryKeyInfo.php';
00071 
00072         // columns have to be loaded first
00073         if (!$this->colsLoaded) $this->initColumns();
00074 
00075         $result = @odbc_primarykeys($this->conn->getResource(), $this->dbname, '', $this->name);
00076 
00077         while (odbc_fetch_row($result))
00078         {
00079             $name = odbc_result($result, 'COLUMN_NAME');
00080 
00081             if (!isset($this->primaryKey))
00082                 $this->primaryKey = new PrimaryKeyInfo($name);
00083 
00084             $this->primaryKey->addColumn($this->columns[$name]);
00085         }
00086 
00087         @odbc_free_result($result);
00088 
00089         $this->pkLoaded = true;
00090     }


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