public function FrxOracle::sqlData in Forena Reports 7.4
Same name and namespace in other branches
- 7.3 plugins/FrxOracle.inc \FrxOracle::sqlData()
Get data based on file data block in the repository.
Parameters
String $block_name:
Array $parm_data:
Query $subQuery:
Overrides FrxDataSource::sqlData
File
- plugins/
FrxOracle.inc, line 68 - 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 sqlData($sql, $options = array()) {
// Load the block from the file
$db = $this->db;
$xml = '';
// Load the types array based on data
$this->types = isset($options['type']) ? $options['type'] : array();
//place this before any script you want to calculate time
if ($sql && $db) {
$time_start = microtime(true);
// 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(Frx::Data()
->currentContext());
$this
->call($sql, $params, array(
'return' => 'clob',
));
$xml = $params['return'];
if (trim($xml)) {
$xml = new SimpleXMLElement($xml);
}
}
else {
$sql = $this->te
->replace($sql);
if ($this->use_oracle_xml && @$options['return_type'] != 'raw') {
$xml = $this
->oracle_xml($sql, 'table');
}
else {
$xml = $this
->php_xml($sql, $options);
}
}
$time_end = microtime(true);
if ($this->debug) {
if (is_object($xml) && method_exists($xml, 'asXML')) {
$d = $xml ? htmlspecialchars($xml
->asXML()) : '';
}
else {
$d = $xml ? htmlspecialchars(print_r($xml, 1)) : '';
}
$elapsed = (int) (($time_end - $time_start) * 1000.0);
$this
->debug("SQL ({$elapsed}ms): " . $sql, '<pre> SQL:' . $sql . "\n XML: " . $d . "\n</pre>");
}
return $xml;
}
}