KoolReport's Forum

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

Postgres View or Materialized Views #3046

Open Tobi opened this topic on on May 11, 2023 - 2 comments

Tobi commented on May 11, 2023

Hi,

Any tips on how to connect koolreport to views or materialized views in postgres?

Sebastian Morales commented on May 12, 2023

You can set up a report to use koolreport\datasources\PostgreSQLDataSource or \koolreport\datasources\PdoDataSource, then use your views in select query like tables:

class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "automakerPostgre"=>array(
                    'host' => 'localhost',
                    'username' => 'root',
                    'password' => '',
                    'dbname' => 'automaker',
                    'class' => "\koolreport\datasources\PostgreSQLDataSource"  
                ),
                "automakerPdoPostgre"=>array(
                    "connectionString"=>"pgsql:host=localhost;dbname=dvdrental",
                    "username"=>"root",
                    "password"=>"",
                    'class' => "\koolreport\datasources\PdoDataSource"  
                ),
            )
        );
    }
    public function setup()
    {
        $this->src('automakerPostgre')
        ->query("SELECT * FROM my_view")
        ->pipe(..)
        ->pipe($this->dataStore(...));
    }

If there's any issue let us know right away. Tks,

Tobi commented on May 12, 2023

Great! Sorted!!

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