ColumnRename

Introduction #

Sometime you need to change the name of columns for easier access. For example, data loaded from CSV which does not have header will result in column name like "column0", "column1" .. Those name are very hard to remember and access. So we may want to change the "column0" to "id" and "column1" to "name".

Usage #

In order to use ColumnRename, you need to register the full class name with use statement and then you can use the ColumnRename process like below:

<?php
use \koolreport\processes\ColumnRename;
class MyReport extends \koolreport\KoolReport
{
    public function setup()
    {
        ...
        ->pipe(new ColumnRename(array(
            "column0"=>"id",
            "column1"=>"name"
        )))
        ...
    }
}

So in above example, we are successfully change name of "column0" to "id" and "column1" to "id". The old name of "column0" and "column1" will be removed and replaced by their new name.