autocomplete for columns

This commit is contained in:
Marcin Łojewski
2018-06-28 20:30:11 +02:00
parent ecb04a331b
commit a257855e07
2 changed files with 8 additions and 4 deletions

View File

@@ -315,7 +315,8 @@ class SettingsController extends Controller
$connection = $this->getConnection();
$platform = PlatformFactory::getPlatform($connection);
$columns = $platform->getColumns(
$this->request->getParam($table)
$this->request->getParam($table),
$this->request->getParam("input")
);
return $columns;

View File

@@ -108,12 +108,13 @@ abstract class AbstractPlatform
/**
* Get all the columns defined in the table.
*
* @param string $table The table name.
* @param string $table The table name.
* @param string $phrase Show only columns containing given phrase.
*
* @return array Array with column names.
* @throws DBALException On a database exception.
*/
public function getColumns($table)
public function getColumns($table, $phrase = "")
{
$platform = $this->connection->getDatabasePlatform();
$query = $platform->getListTableColumnsSQL($table);
@@ -123,7 +124,9 @@ abstract class AbstractPlatform
while ($row = $result->fetch()) {
$name = $this->getColumnName($row);
$columns[] = $name;
if (preg_match("/.*$phrase.*/i", $name)) {
$columns[] = $name;
}
}
return $columns;