Try to write a setup function like this:
public function settings() {
// other code
return array(
"dataSources" => array(
"my_datasource1" => array(
"connectionString" => $connectionString,
"username" => "mydbuser",
"password" => $db_password,
"charset" => "utf8"
)
)
);
}
public function setup() {
$this->src('my_datasource1')
->query("SELECT a, b, c, username from xyztable") // username is a field in my table which I want to show
->pipe($this->dataStore('my_store1'));
}
It will silently fail. At Least I do not see any error in PHP error log with E_ALL. It tries to replace the 'username' with database username declared in function settings()... The query it finally tries to execute is: SELECT a, b, c, 'mydbuser' from xyztable
.
Same happens if you query has these strings: connectionString or password or charset.
Now rewrite as follows:
public function setup() {
$this->src('my_datasource1')
->query("SELECT a, b, c, username from xyztable") // username is a field in my table which I want to show
->params([])
->pipe($this->dataStore('my_store1'));
}
It will start working! Passing an empty params array reinstantiates the $params array being used in these DataSources (protected function bindParams($query,$params)) to replace query params.
HTH,