Join methods
This example shows the usage of DataStore's join, leftJoin, rightJoin, fullJoin methods
First Table
first_id | name |
key_1 |
John |
key_3 |
Peter |
key_5 |
May |
Second Table
second_id | income |
key_1 |
$50,000 |
key_2 |
$60,000 |
key_4 |
$80,000 |
key_5 |
$90,000 |
$joinDataStore = $this->dataStore("first")->join($this->dataStore("second"), array("first_id"=>"second_id"));
Table::create(array("dataSource" => $joinDataStore));
first_id | name | second_id | income |
key_1 |
John |
key_1 |
$50,000 |
key_5 |
May |
key_5 |
$90,000 |
$leftjoinDataStore = $this->dataStore("first")->leftJoin($this->dataStore("second"), array("first_id"=>"second_id"));
Table::create(array("dataSource" => $leftjoinDataStore));
first_id | name | second_id | income |
key_1 |
John |
key_1 |
$50,000 |
key_3 |
Peter |
|
$0 |
key_5 |
May |
key_5 |
$90,000 |
$rightjoinDataStore = $this->dataStore("first")->rightJoin($this->dataStore("second"), array("first_id"=>"second_id"));
Table::create(array("dataSource" => $rightjoinDataStore));
Fatal error: Uncaught Error: Call to undefined method koolreport\core\DataStore::rightJoin() in /srv/users/koolphp/apps/koolreport/public/examples-all/reports/datastores/join/MyReport.view.php:90
Stack trace:
#0 /srv/users/koolphp/apps/koolreport/public/library2/vendor/koolreport/core/src/KoolReport.php(584): include()
#1 /srv/users/koolphp/apps/koolreport/public/examples-all/reports/datastores/join/run.php(5): koolreport\KoolReport->render()
#2 /srv/users/koolphp/apps/koolreport/public/examples-all/helpers/run.example.php(34): include('/srv/users/kool...')
#3 /srv/users/koolphp/apps/koolreport/public/examples-all/reports/datastores/join/index.php(1): include('/srv/users/kool...')
#4 {main}
thrown in /srv/users/koolphp/apps/koolreport/public/examples-all/reports/datastores/join/MyReport.view.php on line 90