/**
  * @see TableInfo::initForeignKeys()
  */
 protected function initForeignKeys()
 {
     // columns have to be loaded first
     if (!$this->colsLoaded) {
         $this->initColumns();
     }
     $result = @odbc_foreignkeys($this->dblink, '', '', '', $this->dbname, '', $this->name);
     while (odbc_fetch_row($result)) {
         $name = odbc_result($result, 'COLUMN_NAME');
         $ftbl = odbc_result($result, 'FKTABLE_NAME');
         $fcol = odbc_result($result, 'FKCOLUMN_NAME');
         if (!isset($this->foreignKeys[$name])) {
             $this->foreignKeys[$name] = new ForeignKeyInfo($name);
             if (($foreignTable = $this->database->getTable($ftbl)) === null) {
                 $foreignTable = new TableInfo($ltbl);
                 $this->database->addTable($foreignTable);
             }
             if (($foreignCol = $foreignTable->getColumn($name)) === null) {
                 $foreignCol = new ColumnInfo($foreignTable, $name);
                 $foreignTable->addColumn($foreignCol);
             }
             $this->foreignKeys[$name]->addReference($this->columns[$name], $foreignCol);
         }
     }
     @odbc_free_result($result);
     $this->fksLoaded = true;
 }
echo "resource? " . is_resource($rh) . "\n";
if ($rh == NULL) {
    echo odbc_errormsg();
    exit(1);
}
while ($rr = odbc_fetch_array($rh)) {
    // we use ODBC 3, so we differ in column type # for date columns
    // this is not a bug
    if ($rr['TYPE_NAME'] == 'datetime') {
        $rr['DATA_TYPE'] = '(hack)';
        $rr['SQL_DATA_TYPE'] = '(hack)';
    }
    var_dump($rr);
}
// foreignkeys
$rh = odbc_foreignkeys($r, '', '', '', '', '', '');
//var_dump($rh);
echo "resource? " . is_resource($rh) . "\n";
if ($rh == NULL) {
    echo odbc_errormsg();
} else {
    while ($rr = odbc_fetch_array($rh)) {
        var_dump($rr);
    }
}
// primarykeys
$rh = odbc_primarykeys($r, '', 'test', 'my_table');
//var_dump($rh);
echo "resource? " . is_resource($rh) . "\n";
if ($rh == NULL) {
    echo odbc_errormsg();