autocomplete for tables
This commit is contained in:
@@ -41,6 +41,7 @@ user_sql.adminSettingsUI = function () {
|
|||||||
$(ids).autocomplete({
|
$(ids).autocomplete({
|
||||||
source: function (request, response) {
|
source: function (request, response) {
|
||||||
var post = $(form_id).serializeArray();
|
var post = $(form_id).serializeArray();
|
||||||
|
post.push({name: "input", value: request["term"]});
|
||||||
$.post(OC.generateUrl(path), post, response, "json");
|
$.post(OC.generateUrl(path), post, response, "json");
|
||||||
},
|
},
|
||||||
minLength: 0,
|
minLength: 0,
|
||||||
|
|||||||
@@ -266,7 +266,8 @@ class SettingsController extends Controller
|
|||||||
try {
|
try {
|
||||||
$connection = $this->getConnection();
|
$connection = $this->getConnection();
|
||||||
$platform = PlatformFactory::getPlatform($connection);
|
$platform = PlatformFactory::getPlatform($connection);
|
||||||
$tables = $platform->getTables();
|
$input = $this->request->getParam("input");
|
||||||
|
$tables = $platform->getTables($input);
|
||||||
|
|
||||||
$this->logger->debug(
|
$this->logger->debug(
|
||||||
"Returning tableAutocomplete(): count(" . count($tables) . ")",
|
"Returning tableAutocomplete(): count(" . count($tables) . ")",
|
||||||
|
|||||||
@@ -49,12 +49,13 @@ abstract class AbstractPlatform
|
|||||||
/**
|
/**
|
||||||
* Get all the tables defined in the database.
|
* 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.
|
* @return array Array with table names.
|
||||||
* @throws DBALException On a database exception.
|
* @throws DBALException On a database exception.
|
||||||
*/
|
*/
|
||||||
public function getTables($schemaPrefix = false)
|
public function getTables($phrase = "", $schemaPrefix = false)
|
||||||
{
|
{
|
||||||
$platform = $this->connection->getDatabasePlatform();
|
$platform = $this->connection->getDatabasePlatform();
|
||||||
|
|
||||||
@@ -68,13 +69,17 @@ abstract class AbstractPlatform
|
|||||||
$result = $this->connection->executeQuery($queryTables);
|
$result = $this->connection->executeQuery($queryTables);
|
||||||
while ($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
$name = $this->getTableName($row, $schemaPrefix);
|
$name = $this->getTableName($row, $schemaPrefix);
|
||||||
$tables[] = $name;
|
if (preg_match("/.*$phrase.*/i", $name)) {
|
||||||
|
$tables[] = $name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->connection->executeQuery($queryViews);
|
$result = $this->connection->executeQuery($queryViews);
|
||||||
while ($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
$name = $this->getViewName($row, $schemaPrefix);
|
$name = $this->getViewName($row, $schemaPrefix);
|
||||||
$tables[] = $name;
|
if (preg_match("/.*$phrase.*/i", $name)) {
|
||||||
|
$tables[] = $name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tables;
|
return $tables;
|
||||||
|
|||||||
Reference in New Issue
Block a user