You are here

private function FrxMSSQL::php_xml in Forena Reports 8

1 call to FrxMSSQL::php_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 144
Oracle specific driver that takes advantage of oracles native XML support

Class

FrxMSSQL
Class FrxMSSQL

Namespace

Drupal\forena\FrxPlugin\Driver

Code

private function php_xml($sql) {
  $db = $this->db;
  $xml = new \SimpleXMLElement('<table/>');
  $rs = mssql_query($sql, $db);
  $rownum = 0;
  while ($row = mssql_fetch_assoc($rs)) {
    $rownum++;
    $row_node = $xml
      ->addChild('row');
    $row_node['num'] = $rownum;
    foreach ($row as $key => $value) {
      $row_node
        ->addChild(strtolower($key), htmlspecialchars($value));
    }
  }
  if ($rs) {
    mssql_free_result($rs);
  }
  return $xml;
}