Skip to content

Commit

Permalink
Add Table options in reverse-engineering (doctrine#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bburnichon committed Nov 20, 2017
1 parent 139e80f commit 079e587
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,21 @@ public function getListTablesSQL()
return "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'";
}

/**
* @param string
* @param string|null $database
* @return string
*/
public function getTableOptionsSQL($table, $database = null)
{
$database = $database ? "'". $database . "'" : 'DATABASE()';

return "SELECT ENGINE as engine, TABLE_COLLATION as collation, ".
"CREATE_OPTIONS as create_options, TABLE_COMMENT as comment ".
"FROM information_schema.TABLES WHERE TABLE_SCHEMA = " . $database . " AND TABLE_NAME = '".
$table . "' AND TABLE_TYPE='BASE TABLE'";
}

/**
* {@inheritDoc}
*/
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ public function listTableDetails($tableName)
}
$indexes = $this->listTableIndexes($tableName);

return new Table($tableName, $columns, $indexes, $foreignKeys, false, array());
$sql = $this->_platform->getTableOptionsSQL($tableName);
$options = $this->_conn->fetchAssoc($sql);

return new Table($tableName, $columns, $indexes, $foreignKeys, false, $options);
}

/**
Expand Down

0 comments on commit 079e587

Please sign in to comment.