KoolReport's Forum

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

Do you have LeftJoin process? #3438

Open Eugene opened this topic on on Apr 29, 2025 - 8 comments

Eugene commented on Apr 29, 2025

To use like $leftjoin = new LeftJoin($user_source,$purchase_source,array("id"=>"user_id"));

Eugene commented on Apr 29, 2025

Ahh... I just noticed that I asked the same question in 2019

https://www.koolreport.com/forum/topics/970

It looks like we do not have it till now. Okeee....

Eugene commented on Apr 29, 2025

Could you tell me please where I am wrong.

I used to do the following:

     $join1 = new Join($spoiled_tmp, $cons1, array("item_id" => "itemId"));
     $join2 = new Join($join1, $cons2, array("item_id" => "itemId"));
     $join2->pipe($this->dataStore('spoiled'));

It worked but I need Left Join in this case so I added ->pipe($this->dataStore('*****')) to the code where I calculate $spoiled_tmp, $cons1 and $cons2 to get spoiled_tmp, cons1 and cons2 Datastores;

and then I do

$joined= $this->dataStore('spoiled_tmp')
            ->leftJoin($this->dataStore('cons1'), array('item_id' => 'itemId'))
            ->leftJoin($this->dataStore('cons2'), array('item_id' => 'itemId'));
$joined->pipe($this->dataStore('spoiled'));

but I got the empty table where the previous code worked.
Eugene commented on May 2, 2025

Guys is everything ok with koolreport support?

If you offer Priority Support with a 24-hour response time from experienced software engineers and data experts — then we expect that commitment to be honored. Otherwise, it undermines the value of the service we're paying for.

Sebastian Morales commented on May 2, 2025

Sorry for the delay. We are having national public holidays this week. We will inspect the left join method and find you a solution by early next week.

Sebastian Morales commented on May 2, 2025

In your MyReport.view.php pls test this left joined datastore:

$joinedDatastore = $this->dataStore('spoiled_tmp')
            ->leftJoin($this->dataStore('cons1'), array('item_id' => 'itemId'))
            ->leftJoin($this->dataStore('cons2'), array('item_id' => 'itemId'));

print_r($joinedDatastore->data());

or:

$joinedDatastore = $this->dataStore('spoiled_tmp')
            ->leftJoin($this->dataStore('cons1'), array('item_id' => 'itemId'))
            ->leftJoin($this->dataStore('cons2'), array('item_id' => 'itemId'));

$finalDatastore = $joinedDatastore->process(new \koolreport\processes\Custom(function($row){
    return $row;
}));

print_r($finalDatastore->data());

Next week, we will also prepare a new left join process for being used in a report setup.

Eugene commented on May 2, 2025

The result is

Array ( )
Sebastian Morales commented on May 5, 2025

Would you mind printing each datastore's data like this and let us know the result:

print_r($this->dataStore('spoiled_tmp')->data()); 
print_r($this->dataStore('cons1')->data()); 
print_r($this->dataStore('cons2')->data()); 

$joinedDatastore = $this->dataStore('spoiled_tmp')
            ->leftJoin($this->dataStore('cons1'), array('item_id' => 'itemId'))
            ->leftJoin($this->dataStore('cons2'), array('item_id' => 'itemId'));

print_r($joinedDatastore->data()); 
Eugene commented 3 days ago

-

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

None