KoolReport's Forum

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

Dashboard: PDOSource connect to Oracle can't use fields. #1911

Closed ccsmick opened this topic on on Feb 18 - 15 comments

ccsmick commented on Feb 18

If setting any fields like Text::create(), DateTime::create() ......., will be lose data.

KoolReport commented on Feb 18

May I know what you mean by losing data?

ccsmick commented on Feb 18

I do the

return AutoMaker::table("mytable")->where("ROWNUM","<",20);

get data show to Dashboard, but I setting the function fields(), Dashboard can't show any data.

KoolReport commented on Feb 18

May you post your code widget code here.

ccsmick commented on Feb 18

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:

ccsmick commented on Feb 19

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 :

KoolReport commented on Feb 19

If you try to add this command run() at query, does it work?

        return AutoMaker::table("oga_file")
            ->select("oga02","oga50")
            ->where("ROWNUM","<",20)
            ->run(); // Let see if it work with fields()
ccsmick commented on Feb 19

I had add ->run(), but same before not work

KoolReport commented on Feb 19

Alright, let me another test: If you don't use Currency, instead you use Text::create("oga50"), does it show correctly?

ccsmick commented on Feb 19

If use Text::create("oga50") will be show this

KoolReport commented on Feb 19

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:

  1. Please look for correct column name from your table.
  2. You can do following:
        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?

ccsmick commented on Feb 20

I try to run return AutoMaker::table("oga_file")

        ->select("oga02")->alias("oga02_alias")
        ->select("oga50")->alias("oga50_alias")
        ->where("ROWNUM","<",20)  

Currency::create("oga50_alias")->USD()->symbol()

also can't work

this is no setting fields

ccsmick commented on Feb 22

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"),

    ];
}
KoolReport commented on Feb 22

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:

https://www.php.net/manual/en/datetime.format.php

ccsmick commented on Feb 22

setting baseFormat("d-M-y") can work.

The problem is solved, thank you very much.

KoolReport commented on Feb 22

Awesome :)

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
solved

None