public function FrxDrupal::sqlData in Forena Reports 7.5
Get data based on file data block in the repository.
Parameters
String $block_name:
Array $parm_data:
Query $subQuery:
Overrides FrxDataSource::sqlData
File
- src/
Driver/ FrxDrupal.php, line 108 - Provides data blocks for native drupal connections using the default drupal connections.
Class
Namespace
Drupal\forena\DriverCode
public function sqlData($sql, $options = array()) {
$rs = $this
->query($sql, $options);
$entity_map = array();
$select_fields = array();
$rownum = 0;
if (!$rs) {
return;
}
if (@$options['return_type'] == 'raw') {
return $rs;
}
$xml = new \SimpleXMLElement('<table/>');
if ($rs && $rs
->columnCount()) {
foreach ($rs as $data) {
$rownum++;
$row_node = $xml
->addChild('row');
$row_node['num'] = $rownum;
foreach ($data as $key => $value) {
$row_node
->addChild($key, htmlspecialchars($value));
}
/* If we are querying entities, we will store away IDs
* for later querying and XML processing in the
* loadEntitys method
*/
if (@$options['entity_type'] && @$options['entity_id']) {
$display = @$options['entity_display'];
$id_key = $options['entity_id'];
$type = $options['entity_type'];
$id = $data->{$id_key};
if ($id) {
$entity_map[$id][] = $row_node;
$select_fields[$id] = $data;
}
}
}
}
if ($entity_map) {
$this
->loadEntities($type, $entity_map, $select_fields, $display);
}
if ($this->debug) {
$d = $xml ? htmlspecialchars($xml
->asXML()) : '';
$this
->debug('SQL: ' . $sql, '<pre> SQL:' . $sql . "\n XML: " . $d . "\n</pre>");
}
return $xml;
}