You are here

function forena_query_autocomplete_simple in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 forena_query/forena_query.inc \forena_query_autocomplete_simple()
  2. 7.4 forena_query.inc \forena_query_autocomplete_simple()

Standard drupal autocomplete that searches for tables or column values if a table is specified.

Parameters

string $repos:

string $str:

1 string reference to 'forena_query_autocomplete_simple'
forena_query_menu in ./forena_query.module
Implementation of hook_menu

File

./forena_query.inc, line 305

Code

function forena_query_autocomplete_simple() {
  $repos = @$_GET['repos'];
  $str = @$_GET['term'];
  $table = @$_GET['table'];
  $alias = @$_GET['alias'];
  $values = array();
  if ($repos) {

    // If we have a table query the columns
    $r = Frx::DataManager()
      ->repository($repos);
    if ($table && $alias) {
      if ($r && method_exists($r, 'searchTableColumns')) {
        $cols = $r
          ->searchTableColumns($table, $str);
        if ($cols) {
          foreach ($cols as $col) {
            $values[] = $alias . '.' . $col;
          }
        }
      }
    }
    else {
      if ($str) {

        // Otherwise query the table
        if ($r && method_exists($r, 'searchTables')) {
          $values = $r
            ->searchTables($str);
        }
      }
    }
  }
  print drupal_json_output($values);
}