Remove Duplicate

How to set duplicate removal in Table

LineProduct NameQty In Stock
Classic Cars 1998 Chrysler Plymouth Prowler 4724
Classic Cars 1995 Honda Civic 9772
Classic Cars 1952 Alpine Renault 1300 7305
Classic Cars 1965 Aston Martin DB5 9042
Classic Cars 1999 Indy 500 Monte Carlo SS 8164
Classic Cars 1992 Ferrari 360 Spider red 8347
Classic Cars 1993 Mazda RX-7 3975
Classic Cars 1985 Toyota Supra 7733
Classic Cars 1969 Dodge Charger 7323
Classic Cars 1969 Dodge Super Bee 1917
Classic Cars 1970 Plymouth Hemi Cuda 5663
Classic Cars 1969 Ford Falcon 1049
Classic Cars 1968 Dodge Charger 9123
Classic Cars 1969 Corvair Monza 6906
Classic Cars 1976 Ford Gran Torino 9127
Classic Cars 1948 Porsche Type 356 Roadster 8990
Classic Cars 2001 Ferrari Enzo 3619
Classic Cars 1968 Ford Mustang 68
Classic Cars 1962 LanciaA Delta 16V 6791
Classic Cars 1972 Alfa Romeo GTA 3252
Classic Cars 1970 Triumph Spitfire 5545
Classic Cars 1948 Porsche 356-A Roadster 8826
Motorcycles 1957 Vespa GS150 7689
Motorcycles 1936 Harley Davidson El Knucklehead 4357
Motorcycles 1969 Harley Davidson Ultimate Chopper 7933
Motorcycles 2003 Harley-Davidson Eagle Drag Bike 5582
Motorcycles 1996 Moto Guzzi 1100i 6625
Motorcycles 2002 Suzuki XREO 9997
Planes P-51-D Mustang 992
Planes 1980s Black Hawk Helicopter 5330
Ships 1999 Yamaha Speed Boat 4259
Trains Collectable Wooden Train 6450
Trucks and Buses 1940 Ford Pickup Truck 2613
Trucks and Buses 1964 Mercedes Tour Bus 8258
Trucks and Buses 1926 Ford Fire Engine 2018
Trucks and Buses 1958 Setra Bus 1579
Trucks and Buses 1957 Chevy Pickup 6125
Vintage Cars 1917 Grand Touring Sedan 2724
Vintage Cars 1941 Chevrolet Special Deluxe Cabriolet 2378
Vintage Cars 1917 Maxwell Touring Car 7913
Vintage Cars 18th Century Vintage Horse Carriage 5992
Vintage Cars 1937 Lincoln Berline 8693
Vintage Cars 1903 Ford Model A 3913
Vintage Cars 1911 Ford Town Car 540
Vintage Cars 1934 Ford V8 Coupe 5649
Vintage Cars 1913 Ford Model T Speedster 4189
Vintage Cars 1936 Mercedes-Benz 500K Special Roadster 8635
Vintage Cars 1928 Mercedes-Benz SSK 548
Vintage Cars 1932 Model A Ford J-Coupe 9354
Vintage Cars 1932 Alfa Romeo 8C2300 Spider Sport 6553

You may remove the duplicate in a column. Normally this feature is used with sorted table. The duplicate values in a column will be remove if they are placed adjacently. This "removeDuplicate" property receives an array of columns which you want to remove duplicate.

<?php
Table::create(array(
    ...
    "removeDuplicate"=>array("productLine")
));
?>
<?php
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php
//Step 1: Load KoolReport
require_once "../../../../koolreport/autoload.php";

use \koolreport\processes\Limit;
use \koolreport\processes\Sort;

//Step 2: Creating Report class
class MyReport extends \koolreport\KoolReport
{
    protected function settings()
    {
        return array(
            "dataSources"=>array(
                "long_data"=>array(
                    "class"=>'\koolreport\datasources\CSVDataSource',
                    "fieldSeparator"=>"|",
                    'filePath'=>dirname(__FILE__)."/../../../databases/products.csv",
                )

            )
        );
    }
    protected function setup()
    {
        $this->src("long_data")
        ->pipe(new Limit(array(50)))
        ->pipe(new Sort(array(
            "productLine"=>"asc",
        )))
        ->pipe($this->dataStore("long_data"));
    }    
}
<?php
    use \koolreport\widgets\koolphp\Table;
?>
<div class="report-content">
    <div class="text-center">
        <h1>Remove Duplicate</h1>
        <p class="lead">How to set duplicate removal in Table</p>
    </div>
    <?php
    Table::create(array(
        "dataSource"=>$this->dataStore('long_data'),
        "columns"=>array(
            "productLine"=>array(
                "label"=>"Line"
            ),
            "productName"=>array(
                "label"=>"Product Name"
            ),
            "quantityInStock"=>array(
                "label"=>"Qty In Stock"
            )
        ),
        "cssClass"=>array(
            "table"=>"table-bordered table-striped table-hover"
        ),
        "removeDuplicate"=>array("productLine")
    ));
    ?>
</div>

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport