You are here

public function FrxOracle::data in Forena Reports 6.2

Same name and namespace in other branches
  1. 6 plugins/FrxOracle.inc \FrxOracle::data()
  2. 7 plugins/FrxOracle.inc \FrxOracle::data()
  3. 7.2 plugins/FrxOracle.inc \FrxOracle::data()

Get data based on file data block in the repository.

Parameters

String $block_name:

Array $parm_data:

Query $subQuery:

File

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

Class

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

Code

public function data($block_name, $params = array(), $clause = '') {

  // Load the block from the file
  $db = $this->db;
  $block = $this
    ->load_block($block_name);
  $xml = '';
  if ($block['source'] && $this
    ->access($block['access']) && $db) {
    $sql = $block['source'];

    // See if this block matches a declare begin end; syntax.
    if (stripos($sql, 'end;') >= stripos($sql, 'begin') && stripos($sql, 'begin') !== FALSE) {
      $params = $this->te
        ->object_to_array(FrxData::instance()
        ->currentContext());
      $this
        ->call($sql, $params, array(
        'return' => 'clob',
      ));
      $xml = $params['return'];
      if (trim($xml)) {
        $xml = new SimpleXMLElement($xml);
      }
    }
    else {
      if ($clause) {
        $sql = 'SELECT * FROM (' . trim($sql, ' ;') . ') ' . $clause;
      }
      $sql = $this->te
        ->replace($sql);
      if ($this->use_oracle_xml) {
        $xml = $this
          ->oracle_xml($sql, $block_name);
      }
      else {
        $xml = $this
          ->php_xml($sql);
      }
    }
    if ($this->debug) {
      $d = $xml ? htmlspecialchars($xml
        ->asXML()) : '';
      $this
        ->debug('SQL: ' . $sql, '<pre> SQL:' . $sql . "\n XML: " . $d . "\n</pre>");
    }
    return $xml;
  }
}