Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions meta/AccessTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,32 @@ protected function consolidateData($DBdata, $asarray = false)
{
$data = [];

if ($this->isGlobalData()) {
foreach ($DBdata as $i => $db_data_row) {
$new_data = [
'id' => $db_data_row['rid'],
...$this->consolidateRowData([$db_data_row], $asarray)
];
$data[] = $new_data;
}
} else {
$data = $this->consolidateRowData($DBdata, $asarray);
}

return $data;
}

/**
* Creates a proper result array from the database data for single row
*
* @param array $DBdata the data row
* @param bool $asarray return data as associative array (true) or as array of Values (false)
* @return array|Value[]
*/
protected function consolidateRowData($DBdata, $asarray = false)
{
$data = [];

$sep = Search::CONCAT_SEPARATOR;

foreach ($this->schema->getColumns(false) as $col) {
Expand Down Expand Up @@ -488,6 +514,15 @@ protected function consolidateData($DBdata, $asarray = false)
return $data;
}

/**
* Determine is the data taken from global struct
* @return bool
*/
protected function isGlobalData()
{
return !$this->pid && !$this->rid;
}

/**
* Builds the SQL statement to select the data for this page and schema
*
Expand All @@ -502,6 +537,12 @@ protected function buildGetDataSQL($idColumn = 'pid')
$QB = new QueryBuilder();
$QB->addTable($stable, 'DATA');
$QB->addSelectColumn('DATA', $idColumn, strtoupper($idColumn));

// add record ids for global data records
if ($this->isGlobalData()) {
$QB->addSelectColumn('DATA', 'rid');
}

$QB->addGroupByStatement("DATA.$idColumn");

foreach ($this->schema->getColumns(false) as $col) {
Expand Down