You are here

private function FrxMSSQL::mssql_xml in Forena Reports 8

Generate xml from sql using the provided f_forena

Parameters

string $sql: SQL statement

Return value

\SimpleXMLElement XML Element

1 call to FrxMSSQL::mssql_xml()
FrxMSSQL::sqlData in src/FrxPlugin/Driver/FrxMSSQL.php
Get data based on file data block in the repository.

File

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

Class

FrxMSSQL
Class FrxMSSQL

Namespace

Drupal\forena\FrxPlugin\Driver

Code

private function mssql_xml($sql, $block) {
  $db = $this->db;

  //$rs->debugDumpParams();
  $fsql = $sql . ' FOR XML AUTO';
  $rs = mssql_query($db, $fsql, array(
    $sql,
    '',
  ));
  if ($rs) {
    $row = mssql_fetch_row($rs);
    $xml_text = $row[0];
  }
  if ($xml_text) {
    $xml = new \SimpleXMLElement($xml_text);
    if ($xml
      ->getName() == 'error') {
      $msg = (string) $xml . ' in ' . $block . '.sql. ';
      $this
        ->app()
        ->error($msg . 'See logs for more info', $msg . ' in <pre> ' . $sql . '</pre>');
    }
  }
  if ($rs) {
    mssql_free_result($rs);
  }
  return $xml;
}