mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
pkrenn: tableList() has been added, three different queries necessary (merged from branches/gsoc)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41709 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
3946432304
commit
9a516662d0
@ -494,14 +494,29 @@ class PDODatabase extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all the tables in the column.
|
||||
* Returns a list of all the tables in the database.
|
||||
* Table names will all be in lowercase.
|
||||
* Returns a map of a table.
|
||||
*/
|
||||
public function tableList() {
|
||||
|
||||
// to be done - SHOW is used extensively but very MySQL specific
|
||||
|
||||
switch ($parameters['type']) {
|
||||
case "mysql":
|
||||
$sql = "SHOW TABLES";
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = "SELECT tablename FROM pg_tables WHERE tablename NOT ILIKE 'pg_%' AND tablename NOT ILIKE 'sql_%'";
|
||||
break;
|
||||
case "mssql":
|
||||
$sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME NOT LIKE 'sysdiagrams%'";
|
||||
break;
|
||||
default:
|
||||
$this->databaseError("This database server is not available");
|
||||
}
|
||||
foreach($dbConn->query($sql) as $record) {
|
||||
$table = strtolower(reset($record));
|
||||
$tables[$table] = $table;
|
||||
}
|
||||
return isset($tables) ? $tables : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user