KoolReport's Forum

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

Fatal error: Uncaught Exception: There is no source available, please add at least one in the settings() #1473

Closed Ed Martin opened this topic on on Jun 4, 2020 - 4 comments

Ed Martin commented on Jun 4, 2020

Hello, I purchased the Pro version a few months back, but have not been able to spend too much time getting KoolReport up and running. I have been using Google Charts to meet deadlines, but really want to understand KoolReport now that I have some time.

I have been trying the tutorial on YouTube that uses Visual Studio Code and xampp. I believe I have followed all the screens but when I render the report I am getting this error message: Fatal error: Uncaught Exception: There is no source available, please add at least one in the settings() in C:\xampp\htdocs\tutorials\get-started\vendor\koolreport\core\src\KoolReport.php:244 Stack trace: #0 C:\xampp\htdocs\tutorials\get-started\salereport\SaleReport.php(25): koolreport\KoolReport->src('automaker') #1 C:\xampp\htdocs\tutorials\get-started\vendor\koolreport\core\src\KoolReport.php(100): SaleReport->setup() #2 C:\xampp\htdocs\tutorials\get-started\salereport\index.php(7): koolreport\KoolReport->__construct() #3 {main} thrown in C:\xampp\htdocs\tutorials\get-started\vendor\koolreport\core\src\KoolReport.php on line 2441. I check the database using phpmyadmin and I was able to run the query as it is in the SaleReport.php function. Any suggestions?

KoolReport commented on Jun 5, 2020

Do you have any "dataSources" settings inside setup() function. Could you please post your SaleReport.php file

Ed Martin commented on Jun 9, 2020

Sorry for the delay...

<?php

class SaleReport extends \koolreport\KoolReport
{
    //Create settings()
    protected function settings()
    {
        return array(
            "datasources"=> array(
                "automaker"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=automaker",
                    "username"=>"edmart",
                    "password"=>"purple10",
                    "charset"=>"utf8"

                )
            )
        );
    }

    //Setup report
    protected function setup()
    {
        //we will get the top ten paying customers
        $this->src("automaker")
        ->query("
            SELECT customers.customerName, sum(payments.amount) as salesamount
            FROM payments
            JOIN customers on customers.customerNumber = payments.customerNumber
            GROUP BY customers.customerName 
            ORDER BY sum(payments.amount) DESC
            LIMIT 10
        ")
        ->pipe($this->dataStore("result"));
    }
}
KoolReport commented on Jun 10, 2020

Please make it "dataSources" not "datasources"

Ed Martin commented on Jun 10, 2020

Thank you!

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
solved

None