You are here

public function FrxDrupal::data in Forena Reports 7.2

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

Get data based on file data block in the repository.

Parameters

String $block_name:

Array $parm_data:

Query $subQuery:

File

plugins/FrxDrupal.inc, line 35
Provides data blocks for native drupal connections using the default drupal connections.

Class

FrxDrupal
@file Provides data blocks for native drupal connections using the default drupal connections.

Code

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

  // Load the block from the file
  $block = $this
    ->load_block($block_name, $clause);
  $xml = '';
  if (trim($block['source']) && $this
    ->access($block['access'])) {
    $sql = $block['source'];
    if ($clause) {
      $sql = 'SELECT * FROM (' . trim($sql, ' ;') . ') forena_table ' . $clause;
    }
    $sql = $this->te
      ->replace($sql);
    $rs = db_query($sql);
    $xml = new SimpleXMLElement('<table/>');
    foreach ($rs as $data) {
      $row_node = $xml
        ->addChild('row');
      foreach ($data as $key => $value) {
        $row_node
          ->addChild($key, htmlspecialchars($value));

        //$row_node->$key = $value;
      }
    }
  }
  return $xml;
}