Commit 0541b30a authored by Kim Hemsø Rasmussen's avatar Kim Hemsø Rasmussen

Added support for foreign keys

parent 7b19e5df
...@@ -154,7 +154,15 @@ class DrizzlePlatform extends AbstractPlatform ...@@ -154,7 +154,15 @@ class DrizzlePlatform extends AbstractPlatform
public function getListTableForeignKeysSQL($table, $database = null) public function getListTableForeignKeysSQL($table, $database = null)
{ {
return "SELECT * FROM DATA_DICTIONARY.FOREIGN_KEYS"; if ($database) {
$database = "'" . $database . "'";
} else {
$database = 'DATABASE()';
}
return "SELECT CONSTRAINT_NAME, CONSTRAINT_COLUMNS, REFERENCED_TABLE_NAME, REFERENCED_TABLE_COLUMNS, UPDATE_RULE, DELETE_RULE" .
" FROM DATA_DICTIONARY.FOREIGN_KEYS" .
" WHERE CONSTRAINT_SCHEMA=" . $database . " AND CONSTRAINT_TABLE='" . $table . "'";
} }
public function getListTableIndexesSQL($table, $database = null) public function getListTableIndexesSQL($table, $database = null)
......
...@@ -50,5 +50,32 @@ class DrizzleSchemaManager extends AbstractSchemaManager ...@@ -50,5 +50,32 @@ class DrizzleSchemaManager extends AbstractSchemaManager
{ {
return $table['TABLE_NAME']; return $table['TABLE_NAME'];
} }
public function _getPortableTableForeignKeyDefinition($tableForeignKey)
{
$columns = array();
foreach (explode(',', $tableForeignKey['CONSTRAINT_COLUMNS']) as $value)
{
$columns[] = trim($value, '`');
}
$ref_columns = array();
foreach (explode(',', $tableForeignKey['REFERENCED_TABLE_COLUMNS']) as $value)
{
$ref_columns[] = trim($value, '`');
}
return new ForeignKeyConstraint(
$columns,
$tableForeignKey['REFERENCED_TABLE_NAME'],
$ref_columns,
$tableForeignKey['CONSTRAINT_NAME'].
array(
'onUpdate' => $tableForeignKey['UPDATE_RULE'],
'onDelete' => $tableForeignKey['DELETE_RULE'],
)
);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment