KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Multiple columns in one table #1432

Closed Jeremiah Cook opened this topic on on May 8, 2020 - 2 comments

Jeremiah Cook commented on May 8, 2020

I might be missing something easy, but here goes.

Consider the following code:

snipped from byItem.php

         $this->src('lookup2')
        ->query("
            select count(*) as count, sum(products_price) as sum, expired_medication, expired_medication_name, expired_index              from `iems_expired`.`tracerplus-expired-2020` expired
                    join `iems_expired`.`expired-reference` reference
                    on `expired`.`expired_medication`=`reference`.`expired_barcode`
                    join `iems_external`.`products` products
                    on reference.`expired_index` = `products`.`products_model`
                    group by expired_index
        ")
        ->pipe(new Group(array(
            "by"=>"expired_index",
            "sum"=>"sum(products_price)",
            "count"=>"count")))
        ->pipe(new Sort(array("count"=>"desc")))
        ->pipe(new Limit(array(600)))
        ->pipe($this->dataStore('lookup2'));
<?php
Table::create(array(
    "dataStore"=>$this->dataStore('lookup2'),
    "columns"=>array(
        "expired_medication_name"=>array("label"=>"Expired Medication"),
        "expired_index"=>array("label"=>"Barcode Number"),
        "sum"=>array("label"=>"Total Dollars"),
        "count"=>array("label"=>"Count"),
    ),
    "cssClass"=>array(
        "table"=>"table table-striped table-bordered"
    )
));
?>

This shows a table with the proper dollar amount but a value of 1 for count. I have ran the query in MySQL and it comes out correctly. What am I missing?

Jeremiah

Jeremiah Cook commented on May 8, 2020

I fixed my own problem.

Removing "count"=>"count" from the group worked just fine and brought everything in line.

Thanks anyways :-)

KoolReport commented on May 8, 2020

That's great :)

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

None