Hello, Ravin,
I have solved this in an analogous way for MySQL like this:
External file "DBSettings_odsreadall.php" (whatever YOU call it then):
<?php
$DATABASESERVER = 'localhost';
$DATABASENAME = 'databasename';
$DATABASEUSERNAME = 'hellohereami';
$DATABASEPASSWORD = 'whatever';
$DATABASETYPE = 'MySQL';
?>
And then the "index.php" file, part of which contains:
[...]
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
require_once("../../DBSettings.php");
} else {
include_once("DBSettings_odsreadall.php");
}
global $DATABASESERVER, $DATABASEUSERNAME, $DATABASEPASSWORD, $DATABASENAME;
[...]
And then, still in "index.php":
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$report = new Report_global(array(
"connectionString"=>"mysql:host=127.0.0.1;port=8889;dbname=$DATABASENAME",
"username"=>$DATABASEUSERNAME,
"password"=>$DATABASEPASSWORD
));
} else {
$report = new Report_global(array(
"connectionString"=>"mysql:host=127.0.0.1;port=3306;dbname=$DATABASENAME",
"username"=>$DATABASEUSERNAME,
"password"=>$DATABASEPASSWORD
));
}
$report->run()->render();
And finally the file "Report.php" which contains the mode to address the database:
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
class Report_global extends \koolreport\KoolReport {
use \koolreport\clients\Bootstrap;
protected function settings() {
return array(
"dataSources"=>array(
"patient"=>array(
"connectionString"=>$this->params["connectionString"],
"username"=>$this->params["username"],
"password"=>$this->params["password"],
"charset"=>"utf8"
),
),
"assets"=>array(
"path"=>"assets",
//"url"=>"http://localhost:8888/adipositas/admin/centers/koolreport/assets"
"url"=>"http://172.172.10.10:8888/adipositas/admin/centers/koolreport/assets"
//"url"=>"http://" . $_SERVER['SERVER_NAME'] . ":8888" . "/adipositas/admin/koolreport/assets"
//"url"=>"https://" . $_SERVER['SERVER_NAME'] . "/adipositas/admin/koolreport/assets"
)
);
}
}
} else {
class Report_global extends \koolreport\KoolReport {
use \koolreport\clients\Bootstrap;
protected function settings() {
return array(
"dataSources"=>array(
"patient"=>array(
"connectionString"=>$this->params["connectionString"],
"username"=>$this->params["username"],
"password"=>$this->params["password"],
"charset"=>"utf8"
),
),
"assets"=>array(
"path"=>"assets",
//"url"=>"http://localhost:8888/adipositas/admin/centers/koolreport/assets"
//"url"=>"http://172.172.10.10:8888/adipositas/admin/centers/koolreport/assets"
//"url"=>"http://" . $_SERVER['SERVER_NAME'] . ":8888" . "/adipositas/admin/koolreport/assets"
"url"=>"https://" . $_SERVER['SERVER_NAME'] . "/adipositas/admin/centers/koolreport/assets"
)
);
}
}
}
I hope that helps you. Admittedly a bit complicated, but I have to take care of different OS, different versions of PHP, and different versions of databases and credentials.