You are here

public function FrxMSSQL::sqlData in Forena Reports 8

Get data based on file data block in the repository.

Parameters

string $sql: Query to execute

array $options: Key/value pair or array containing parameter type ifnormation for the query.

Return value

\SimpleXMLElement | array Data from executed sql query.

File

src/FrxPlugin/Driver/FrxMSSQL.php, line 83
Oracle specific driver that takes advantage of oracles native XML support

Class

FrxMSSQL
Class FrxMSSQL

Namespace

Drupal\forena\FrxPlugin\Driver

Code

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

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

  // Load the types array based on data
  $this->types = isset($options['type']) ? $options['type'] : array();
  $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_mssql_xml) {
      $xml = $this
        ->mssql_xml($sql, 'table');
    }
    else {
      $xml = $this
        ->php_xml($sql);
    }
    if ($this->debug) {
      if ($xml) {
        $d = htmlspecialchars($xml
          ->asXML());
      }
      $this
        ->debug('SQL: ' . $sql, '<pre> SQL:' . $sql . "\n XML: " . $d . "\n</pre>");
    }
    return $xml;
  }
  else {
    return NULL;
  }
}