autocomplete for tables

This commit is contained in:
Marcin Łojewski
2018-06-28 20:16:43 +02:00
parent ffb28c62be
commit ecb04a331b
3 changed files with 12 additions and 5 deletions

View File

@@ -49,12 +49,13 @@ abstract class AbstractPlatform
/**
* Get all the tables defined in the database.
*
* @param bool $schemaPrefix Show schema name in the results.
* @param string $phrase Show only tables containing given phrase.
* @param bool $schemaPrefix Show schema name in the results.
*
* @return array Array with table names.
* @throws DBALException On a database exception.
*/
public function getTables($schemaPrefix = false)
public function getTables($phrase = "", $schemaPrefix = false)
{
$platform = $this->connection->getDatabasePlatform();
@@ -68,13 +69,17 @@ abstract class AbstractPlatform
$result = $this->connection->executeQuery($queryTables);
while ($row = $result->fetch()) {
$name = $this->getTableName($row, $schemaPrefix);
$tables[] = $name;
if (preg_match("/.*$phrase.*/i", $name)) {
$tables[] = $name;
}
}
$result = $this->connection->executeQuery($queryViews);
while ($row = $result->fetch()) {
$name = $this->getViewName($row, $schemaPrefix);
$tables[] = $name;
if (preg_match("/.*$phrase.*/i", $name)) {
$tables[] = $name;
}
}
return $tables;