You are here

public function FrxRepoMan::sqlData in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.4 FrxRepoMan.inc \FrxRepoMan::sqlData()

Execute sql on a provider

Parameters

$provider String Data provider index to reference:

$sql String sql command to execute:

File

./FrxRepoMan.inc, line 241
FrxRepoMan.inc Enter description here ... @author davidmetzler

Class

FrxRepoMan
@file FrxRepoMan.inc Enter description here ... @author davidmetzler

Code

public function sqlData($provider, $sql, $parms = array()) {
  $xml = '';

  //Intstantiate the provider
  $o = $this
    ->repository($provider);
  $repos = @$this->repositories[$provider];
  if (isset($repos['enabled']) && !$repos['enabled']) {
    return '';
  }

  //Populate user callback.
  if (isset($repos['user callback'])) {
    $user_fn = $repos['user callback'];
    if (is_callable($user_fn)) {
      $current_user = $user_fn();
      $parms['current_user'] = $current_user;
    }
  }
  if ($o && $sql) {
    Frx::Data()
      ->push($parms, 'parm');

    // Parse the sql file
    $data = $o
      ->parseSQLFile($sql);

    //now get the built SQL back
    $sql = $data['source'];
    $xml = $o
      ->sqlData($sql, @$data['options']);
    Frx::Data()
      ->pop();
  }
  return $xml;
}