KoolReport's Forum

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

Need help on MySQL #805

Open mark0300 opened this topic on on Apr 15, 2019 - 3 comments

mark0300 commented on Apr 15, 2019

Hi there,

I have done the following: index.php:


<?php
// index.php: Just a bootstrap file
require_once "SalesByQuarter.php";

$salesByQuarter = new SalesByQuarter;
$salesByQuarter->run()->render();


SalesByQuarter.php:

<?php
require_once "../koolreport/autoload.php";

use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;

class QuarterSaleReport extends \koolreport\KoolReport
{
    function settings()
    {
        return array(
            "dataSources"=>array(
                "mydata"=>array(
                    'connectionString' => "mysql:host=localhost;dbname=mydbname",
                    'username' => 'root',
                    'password' => 'xxxxxxx',
                    'charset' => 'utf8'
                ),
            )
        );
    }
    protected function setup()
    {
        $this->src("mydata")
        ->query("select tran_date, ov_amount from 0_debtor_trans")
        ->pipe(new TimeBucket(array(
            "bucket"=>"quarter"
        )))
        ->pipe(new Group(array(
            "by"=>"tran_date",
            "sum"=>"ov_amount"
        )))
        ->pipe($this->dataStore("sale_by_quarter"));
    }
}

SalesByQuarter.view.php

<?php 
    use \koolreport\widgets\google\ColumnChart;
?>
<html>
    <head>
        <title>Quarter Sale Report</title>
    </head>
    <body>
        <?php 
        ColumnChart::create(array(
            "dataStore"=>$this->dataStore("sale_by_quarter")
        ));
        ?>
    </body>
</html>

After setting up the above 3 files, I ran the index.php and it returned with error 500.

I went thru' a few times and I couldn't figure out what went wrong... Could some one help to point out if there is any issues with the codes?

Many thanks.

/Mark

KoolReport commented on Apr 15, 2019

In the top of index.php, please put:

error_reporting(E_ALL);

Let PHP tell what went wrong otherwise we fight in bind.

mark0300 commented on Apr 17, 2019

Thanks and I found the issue. It was due to the directory not properly specified. It should be just one dot instead of two dots in the following code:

require_once "../koolreport/autoload.php"; 

Correct code:

require_once "./koolreport/autoload.php"; 

/Mark

KoolReport commented on Apr 17, 2019

I see, great that you find out the issue :)

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
None yet

None