You are here

private function FrxPostgres::postgres_xml in Forena Reports 6.2

Same name and namespace in other branches
  1. 6 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
  2. 7 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
  3. 7.2 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
  4. 7.3 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
  5. 7.4 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()

Generate xml from sql using the provided f_forena

Parameters

unknown_type $sql:

Return value

unknown

1 call to FrxPostgres::postgres_xml()
FrxPostgres::data in plugins/FrxPostgres.inc
Get data based on file data block in the repository.

File

plugins/FrxPostgres.inc, line 93
Oracle specific driver that takes advantage of oracles native XML support

Class

FrxPostgres
@file Oracle specific driver that takes advantage of oracles native XML support

Code

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

  //$rs->debugDumpParams();
  $fsql = 'select query_to_xml($1,true,false,$2);';
  $rs = pg_query_params($db, $fsql, array(
    $sql,
    '',
  ));
  $xml_text = '';
  if ($rs) {
    $row = pg_fetch_row($rs);
    $xml_text = $row[0];
  }
  $xml = null;
  if ($xml_text) {
    $xml = new SimpleXMLElement($xml_text);
    if ($xml
      ->getName() == 'error') {
      $msg = (string) $xml . ' in ' . $block . '.sql. ';
      $this
        ->error($msg . 'See logs for more info', $msg . ' in <pre> ' . $sql . '</pre>');
    }
    if (!$xml
      ->children()) {
      $xml = '';
    }
  }
  if ($rs) {
    pg_free_result($rs);
  }
  return $xml;
}