You are here

public function FrxPostgres::searchTableColumns in Forena Reports 8

Overrides DriverBase::searchTableColumns

File

src/FrxPlugin/Driver/FrxPostgres.php, line 263
Postgres specific driver that takes advantage of native XML support

Class

FrxPostgres
Class FrxPostgres

Namespace

Drupal\forena\FrxPlugin\Driver

Code

public function searchTableColumns($table, $str) {
  $str .= '%';
  $db = $this->db;
  $sql = $this
    ->searchTableColumnsSQL();
  $str = pg_escape_string($str);
  $str = "'{$str}'";
  $sql = str_replace(':str', $str, $sql);
  $table = pg_escape_string($table);
  $table = "'{$table}'";
  $sql = str_replace(':table', $table, $sql);
  $info = $this
    ->parseConnectionStr();
  $database = isset($info['dbname']) ? $info['dbname'] : @$info['database'];
  $database = pg_escape_string($database);
  $database = "'{$database}'";
  $sql = str_replace(':database', $database, $sql);
  $rs = @pg_query($sql);
  $rownum = 0;
  $tables = array();
  if ($rs) {
    $tables = pg_fetch_all_columns($rs, 0);
  }
  if ($rs) {
    pg_free_result($rs);
  }
  return $tables;
}