KoolReport's Forum

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

Print table from database postgresql #2584

Open fiuncho opened this topic on on Feb 19, 2022 - 5 comments

fiuncho commented on Feb 19, 2022

Hi team

I'm new on Koolreport

I have try to build a simple example reading data from postgresql database to a table. But the result it is not too correct. At the end, koolreport prints:

            $this->dataStore('db_sql_data')

and the data as a table with all fields:

    $this->dataStore('db_sql_data')
    model	system	time_metr

Could you help me to looking for the issue?

Note:

I tried to do the same by php and pg connector, and the test was ok.

Thanks

Sebastian Morales commented on Feb 21, 2022

Would you pls post your report's setup and view php code as well as screenshots of the output? Tks,

fiuncho commented on Feb 23, 2022

Thanks for your reponse.

This is an output image

It never do the next step

fiuncho commented on Feb 24, 2022

I forgoten to write the code. I think it could be usefull. This is it:

class TestDB extends \koolreport\KoolReport
{

    public function settings()
    {
        return array(
            "dataSources"=>array(
                "logml_db_conn"=>array(
                    'host' => 'localhost',
                    'username' => '************',
                    'password' => '***********',
                    'dbname' => 'logmldb',
                    'charset' => 'utf8',  
                    'class' => "\koolreport\datasources\PostgreSQLDataSource"  
                ),
            )
        );
    }
    public function setup()
    {
        $select_query = "SELECT * FROM ml_log_table
            Where date_part('year', timestamp) = :pyear
            and time_metr = :ptime_metr
        ";

        $this->src('logml_db_conn')
        ->query($select_query)
        ->params(array(":pyear"=>2022,":ptime_metr"=>"SEC"))
        ->pipe($this->dataStore('kl_data'));
    }    
}
Sebastian Morales commented on Feb 24, 2022

Oh, that output is most likely because the report could not find its view file so it dumps all of its datastores' data in the most basic way. Pls make sure there's a file called "TestDB.view.php". Depending on your OS, the file name must be case sensitively correct or not.

fiuncho commented on Feb 24, 2022

Yes!!!

Thanks Sebastian!!!

Muchas Gracias, has dado en el clavo!!!, era el nombre, mayusculas y minĂºsculas.!!! You are right, it was the name, the class name and the file name must have the same case sensitive

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