/** * Display final output. * @param array $fullRows * @param array $actions * @throws \Exception */ protected function displayRows(array $fullRows, array $actions) { // The position is the same for $fullRows and $changedRows (for cross referencing purposes). $rowCount = 0; foreach ($fullRows as $row) { // First column is the row's table and then all the columns. $header = array_merge(array($row->table), array_keys((array) $row->data)); // Add action type as the first column in the data row. $line = array($this->dbms->getTrackTypeDescription($row->type)); $padding = strlen($header[0]) > strlen($line[0]) ? array(strlen($header[0])) : array(strlen($line[0])); // Column counter. $pos = 0; foreach ($row->data as $column => $value) { ++$pos; if ($this->valueDisplayLength > 0 && strlen($value) > $this->valueDisplayLength) { $value = substr($value, 0, 20) . '...'; } // Make sure the column's display width is long enough. $padding[] = strlen($value) > strlen($header[$pos]) ? strlen($value) : strlen($header[$pos]); // Highlight only changed columns. if ($row->type == Database::TRIGGER_ACTION_UPDATE) { if (isset($actions[$rowCount]->data->{$column}) && $row->primarycolumn != $column) { $value = $this->display->getColourText($value, 'yellow'); } } $line[] = $value; } // Display line. $this->display->setHeader($header); $this->display->setPadding($padding); $this->display->showHeader(); $this->display->showLine($line); $this->display->showLine(); ++$rowCount; } }