private function FrxPostgres::postgres_xml in Forena Reports 7.4
Same name and namespace in other branches
- 6.2 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
- 6 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
- 7 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
- 7.2 plugins/FrxPostgres.inc \FrxPostgres::postgres_xml()
- 7.3 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::sqlData in plugins/
FrxPostgres.inc - Get data based on file data block in the repository.
File
- plugins/
FrxPostgres.inc, line 92 - Postgres specific driver that takes advantage of native XML support
Class
- FrxPostgres
- @file Postgres specific driver that takes advantage of 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,
'',
));
$e = pg_last_error();
if ($e) {
$text = $e;
if (!$this->block_name) {
$short = t('%e', array(
'%e' => $text,
));
}
else {
$short = t('SQL Error in %b.sql', array(
'%b' => $this->block_name,
));
}
$this
->error($short, $text);
return;
}
$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;
}