diff --git a/tbl_relation.php3 b/tbl_relation.php3 new file mode 100644 index 000000000..82ef0d5a2 --- /dev/null +++ b/tbl_relation.php3 @@ -0,0 +1,150 @@ + 0) { + while ($curr_field = mysql_fetch_array($fi_rs)){ + if($curr_field["Key_name"]=="PRIMARY"){ + $field_full = $curr_field["Table"].".".$curr_field["Column_name"]; + $field_v = $curr_field["Table"]."->".$curr_field["Column_name"]; + break; + }else if($curr_field["non_unique"]==0){ + // if we can't find a primary key we take any unique one + $field_full = $curr_field["Table"].".".$curr_field["Column_name"]; + $field_v = $curr_field["Table"]."->".$curr_field["Column_name"]; + } // end if + } // end while + + $selectboxall[$field_full] = $field_v; + } // end if (mysql_num_rows) + } + if($curr_table[0]==$cfg['Server']['relation']){ + $rel_work=TRUE; + } + } + // create Array of Relations (Mike Beck) + if($rel_work){ + $rel_query = "SELECT master_field,concat(foreign_table,'.',foreign_field) as rel "; + $rel_query .= 'FROM ' . $cfg['Server']['relation']; + $rel_query .= ' WHERE master_table = \'' . $table.'\''; + + $relations = @mysql_query($rel_query) or PMA_mysqlDie('', $rel_query, '', $err_url); + while ($relrow = @mysql_fetch_array($relations)){ + $rel_col = $relrow['master_field']; + $rel_dest[$rel_col]=$relrow['rel']; + } + } +} + +// now find out the columns of our $table +$col_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table); +$col_rs = mysql_query($col_query) or PMA_mysqlDie('',$col_query,'',$err_url_0); + +if(mysql_num_rows($col_rs)>0){ + ?> +