Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
If not setting function fields() can get data
class PaymentTable extends Table
{
protected function dataSource()
{
return AutoMaker::table("oga_file")
->select("oga02","oga50")
->where("ROWNUM","<",20);
}
}
like this:
if I setting function fields()
class PaymentTable extends Table
{
protected function dataSource()
{
->select("oga02","oga50")
->where("ROWNUM","<",20);
}
protected function fields()
{
return [
DateTime::create("oga02")
->displayFormat("M jS, Y"),
Currency::create("oga50")
->USD()
->symbol(),
];
}
}
show like this:
if only setting Currency::create
class PaymentTable extends Table
{
protected function dataSource()
{
return AutoMaker::table("oga_file")
->select("oga01","oga02","oga50")
->where("ROWNUM","<",20);
}
protected function fields()
{
return [
Currency::create("oga50")
->USD()
->symbol(),
];
}
}
will be show $0 :
I guess the return key field from datasource is not "oga50", it could be "Oga50", I mean there is case sensitive here that makes "oga50" is not the key. That's why it return null. The auto generated fields (trigger when there is no fields() method) work because correctly catch the correct case-sensitive key. There are two solution:
return AutoMaker::table("oga_file")
->select("oga02")->alias("oga02_alias")
->select("oga50")->alias("oga50_alias")
->where("ROWNUM","<",20)
and then you do:
Currency::create("oga50_alias")->USD()->symbol()
Let me know which way works?
I found the problem, now can get data, but DataTime::create() this function cant work.
Text::create() can work
code: protected function dataSource()
{
return AutoMaker::table("oga_file")
->select("oga02")->alias("oga02_alias")
->select("oga50")->alias("oga50_alias")
->where("ROWNUM","<",20);
}
protected function fields()
{
return [
Currency::create("OGA50_ALIAS")->USD()->symbol()->label("PRICE"),
Text::create("OGA02_ALIAS")->label("DATE"),
// Use the DateTime::create() or Date::create can't work // Date::create("OGA02_ALIAS"),
];
}
I see, so the previous issue was solved by capitalizing the key, so I guess you can remove the alias() and use directly the key "OGA50"
for example.
For the date issue, your date seems not in standard format of Y-m-d, so you need to input the format like following:
Date::create("OGA02")
->baseFormat("d-M-y"); // 02-Apr-10
->displayFormat("M j"); // This is format to display
Let us know if it works.
More reference:
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo