Update on Oracle Driver

I added the code to display the foreign keys on the table description! cheers!
This commit is contained in:
JorgeHeredia 2014-09-03 14:10:52 -03:00 committed by Jakub Vrana
parent 9e28e9f7ae
commit 3e769815bf

View file

@ -317,7 +317,29 @@ ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) {
}
function foreign_keys($table) {
return array(); //!
$return = array();
$query = "SELECT c_list.CONSTRAINT_NAME as NAME,
c_src.COLUMN_NAME as SRC_COLUMN,
c_dest.OWNER as DEST_DB,
c_dest.TABLE_NAME as DEST_TABLE,
c_dest.COLUMN_NAME as DEST_COLUMN,
c_list.DELETE_RULE as ON_DELETE
FROM ALL_CONSTRAINTS c_list, ALL_CONS_COLUMNS c_src, ALL_CONS_COLUMNS c_dest
WHERE c_list.CONSTRAINT_NAME = c_src.CONSTRAINT_NAME
AND c_list.R_CONSTRAINT_NAME = c_dest.CONSTRAINT_NAME
AND c_list.CONSTRAINT_TYPE = 'R'
AND c_src.TABLE_NAME = " . q($table);
foreach (get_rows($query) as $row) {
$return[$row['NAME']] = array(
"db" => $row['DEST_DB'],
"table" => $row['DEST_TABLE'],
"source" => array($row['SRC_COLUMN']),
"target" => array($row['DEST_COLUMN']),
"on_delete" => $row['ON_DELETE'],
"on_update" => null,
);
}
return $return;
}
function truncate_tables($tables) {