From a257855e07ec81b580f401da65f17420d099fafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81ojewski?= Date: Thu, 28 Jun 2018 20:30:11 +0200 Subject: [PATCH] autocomplete for columns --- lib/Controller/SettingsController.php | 3 ++- lib/Platform/AbstractPlatform.php | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 8c4a9fb..a192daf 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -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; diff --git a/lib/Platform/AbstractPlatform.php b/lib/Platform/AbstractPlatform.php index 38d8f61..59052d4 100644 --- a/lib/Platform/AbstractPlatform.php +++ b/lib/Platform/AbstractPlatform.php @@ -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;