You are here

public function FrxPostgres::sqlData in Forena Reports 8

Get data based on file data block in the repository.

Parameters

string $sql : Query to execute

array $options: array containing type configuration data.

Return value

SimpleXMLElement | array The data returned from the query.

File

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

Class

FrxPostgres
Class FrxPostgres

Namespace

Drupal\forena\FrxPlugin\Driver

Code

public function sqlData($sql, $options = array()) {

  // Load the block from the file
  $db = $this->db;
  $xml = '';

  // Load the types array based on data
  $this->types = isset($options['type']) ? $options['type'] : array();
  if ($sql && $db) {
    $sql = $this->te
      ->replace($sql);
    if ($this->use_postgres_xml) {
      $xml = $this
        ->postgres_xml($sql, 'table');
    }
    else {
      $xml = $this
        ->php_xml($sql);
    }
    if ($this->debug) {
      $d = '';
      if ($xml) {
        $d = htmlspecialchars($xml
          ->asXML());
      }
      $this
        ->debug('SQL: ' . $sql, '<pre> SQL:' . $sql . "\n XML: " . $d . "\n</pre>");
    }
    return $xml;
  }
  else {
    return NULL;
  }
}