Piwik\DataTable::renameColumn PHP Method

renameColumn() public method

Rename a column in every row. This change is applied recursively to all subtables.
public renameColumn ( string $oldName, string $newName )
$oldName string Old column name.
$newName string New column name.
    public function renameColumn($oldName, $newName)
    {
        foreach ($this->rows as $row) {
            $row->renameColumn($oldName, $newName);
            $subTable = $row->getSubtable();
            if ($subTable) {
                $subTable->renameColumn($oldName, $newName);
            }
        }
        if (!is_null($this->summaryRow)) {
            $this->summaryRow->renameColumn($oldName, $newName);
        }
    }

Usage Example

 /**
  * Note: public only for use in closure in PHP 5.3.
  */
 public function renameColumnsAfterAggregation(DataTable $table, $columnsToRenameAfterAggregation = null)
 {
     // Rename columns after aggregation
     if (is_null($columnsToRenameAfterAggregation)) {
         $columnsToRenameAfterAggregation = self::$columnsToRenameAfterAggregation;
     }
     foreach ($columnsToRenameAfterAggregation as $oldName => $newName) {
         $table->renameColumn($oldName, $newName, $this->isAggregateSubTables());
     }
 }
All Usage Examples Of Piwik\DataTable::renameColumn