KoolReport's Forum

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

How to count the number of row from a Table #3337

Open Akim opened this topic on on Sep 16 - 2 comments

Akim commented on Sep 16

Hi Folks,

I'm searching for getting the nomber of rows returned from server.

Bellow is my test : ** Test1.php *****

class Test1 extends \koolreport\KoolReport
{
    use \koolreport\amazing\Theme;
    function settings()
    {	$config = include "./config/config.php";
		return array(
            "dataSources"=>array("MyCustomers"=>$config["automaker"])
        );
    } 
    protected function setup()    {	} 
}

** Test1.view.php *

<div >
<?php
	$MyTable = Table::create(array(   "name"=>"rty",	
								"paging"=>array("pageSize"=>5),
								"dataSource"=>function() {return $this
															->src('MyCustomers')
															->query("select * from customers");
															},
						));									
?>
</div>
<div class="text-center">
    <?php 	$MyCount = 0;
		/* how to get the number of rows from the datasource of the table $MyTable?*/
	?>		
<h6>Rowq count : <?php echo $MyCount?></h6>
</div>

Thanks.

Sebastian Morales commented on Sep 17

So far the Table class has not allowed access to its DataStore object. Thus, you can not know its number of rows with a functional dataSource property like that. One solution is to pipe to a DataStore in your report's setup method. Then in your report's view, use that DataStore for the Table widget and count its rows via:

https://www.koolreport.com/docs/datastore/overview/#aggregated-methods-count

Akim commented on Sep 23

Thank you Sebastian.

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