KoolReport's Forum

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

Accessing the settings() #1743

Open Richb201 opened this topic on on Dec 2, 2020 - 4 comments

Richb201 commented on Dec 2, 2020

I have a form that seems to work OK. In settings it opens a handle to my tables with:

function settings(){
        return array(
            "dataSources"=>array(
                "substantiator" => array(
                    "connectionString" => "mysql:host=mysql;dbname=substantiator",
                    "username" => "admin",
                    "password" => "sadfxxxx",
                    "charset" => "utf8"
                ),
            )
        ); 
  }

And then in the setup() I do queries such as

        $this->src('substantiator')
            ->query("SELECT  bus_comp FROM business_components WHERE campaign='$campaign' AND email='$email'")
            ->pipe($this->dataStore("business_components"));

I have a need to return a single row from one of my tables so I can use two of the values as keys. Here is the query: $sql="SELECT email, campaign FROM employees where user='$userId');

Can I create a ->pipe to do this? If i do, how can I retrieve the email and the campaign fields from the SELECT? This will need to be done at the very top of setup() because many of the other queries depend on it.

Sebastian Morales commented on Dec 3, 2020

Richard, pls try this requestDataSending() method:

    $this->src('substantiator')
            ->query("SELECT  bus_comp FROM business_components WHERE campaign='$campaign' AND email='$email'")
            ->pipe($this->dataStore("temp_business_components"))
            ->requestDataSending();

    $data = $this->dataStore("temp_business_components")->data();
Richb201 commented on Dec 3, 2020

Thanks. works great

Richb201 commented on Dec 3, 2020

I have used your example and managed to get the $email and $campaign from one of the tables.

        $data = $this->dataStore("employees")->data();
         $email=$data[0]['email'];
        $campaign=$data[0]['campaign'];

Now, besides using these values when building the datastores for use in the view, I also need them in text boxes in the view(actually, I need to make two of them invisible). Here is how I am setting up the ParamValues

protected function defaultParamValues()
{
    return array(
        "dateRange"=>array('2017-07-01','2017-07-31'),
        "campaign"=>$campaign,
        "taxyear"=>$taxyear,
        "admin_email"=>$email,
        "select"=>"",
        "multiSelect"=>array(),
        "radioList"=>"",
        "checkBoxList"=>array(),
        "startDatePicker"=>date("Y-m-d 00:00:00"),
        "endDatePicker"=>date("Y-m-d 23:59:59"),
        "rangeSliderOne"=>array(50),
        "rangeSliderTwo"=>array(20,80),
    );
}

In the view I have put :

   <?php TextBox::create(array("name"=>"campaign")) ?>
    <?php TextBox::create(array("name"=>"taxyear")) ?>
    <?php TextBox::create(array("name"=>"admin_email")) ?>

The boxes appear but they are blank. What am I doing wrong?

Richb201 commented on Dec 4, 2020

moved to a separate post

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
solved

None