KoolReport's Forum

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

Koolreport\core\WidgetContainer::$queryParams with codeigniter #2556

Closed Shaurya Bajaj opened this topic on on Feb 3, 2022 - 19 comments

Shaurya Bajaj commented on Feb 3, 2022

Hello team, I am trying to access kool report with my existing code igniter application. I have done Barchar,ColumnChart and Table with same configration and it is runing fine. On visual query I am having errors. tried to troubleshoot and sems like on visualQuery.php/ onInit function where this line is having error because in $report queryParams is not define.

  $queryParams = Util::get($report->queryParams, $this->name);

I am having following error, kindly guide me what I am doing wrong.

Error : 

Undefined property: koolreport\core\WidgetContainer::$queryParams Filename: visualquery/VisualQuery.php Line Number: 85

and

Type: Error

Message: Call to undefined method koolreport\core\WidgetContainer::paramsToValue()

Filename: C:\wamp64\www\my-folder\assets\koolreport\visualquery\VisualQuery.php

Line Number: 86

my report.php file

 /**
 * Class Reports
 */
 class Reports extends Admin_Controller
{
    public function graphical_report() {
        $data['report'] = new MyReport;
        $this->layout->set($data);
        $this->layout->buffer('content', 'reports/graphical_report_view');
        $this->layout->render();
    }
 }
 require_once APPPATH.'..\assets\koolreport\core\autoload.php';
 use \koolreport\core\Utility as Util;
 class MyReport extends \koolreport\KoolReport
 {
    use \koolreport\bootstrap4\Theme;
    // use \koolreport\clients\Bootstrap;
    use \koolreport\visualquery\Bindable;
        

    public function defineSchemas()
    {
        return [
            "salesSchema" => array(
                "tables" => [
                    "customers" => array(
                        "{meta}" => [
                            "alias" => "Table Customers"
                        ],
                        "customerNumber" => array(
                            "alias" => "Customer Number",
                        ),
                        "customerName" => array(
                            "alias" => "Customer Name",
                        ),
                    ),
                    "orders" => array(
                        "{meta}" => [
                            "alias" => "Table Orders"
                        ],
                        "orderNumber" => array(
                            "alias" => "Order Number"
                        ),
                        "orderDay" => array(
                            "alias" => "Order Day",
                            "expression" => "date(orderDate)",
                            "type" => "date",
                        ),
                        "orderDate" => array(
                            "alias" => "Order Date",
                            "type" => "datetime",
                        ),
                        "orderMonth" => [
                            "expression" => "month(orderDate)",
                            "type" => "number",
                        ]
                        // "customerNumber"=>array(
                        //    "alias"=>"Customer Number"
                        // )
                    ),
                    "orderdetails" => array(
                        "{meta}" => [
                            "alias" => "Order Details"
                        ],
                        // "orderNumber"=>array(
                        //     "alias"=>"Order Number"
                        // ),
                        "quantityOrdered" => array(
                            "alias" => "Quantity",
                            "type" => "number",
                        ),
                        "priceEach" => array(
                            "alias" => "Price Each",
                            "type" => "number",
                            "decimal" => 2,
                            "prefix" => "$",
                        ),
                        // "productCode"=>array(
                        //     "alias"=>"Product Code"
                        // ),
                        "cost" => [
                            // "expression" => "orderdetails.quantityOrdered * orderdetails.priceEach",
                            "expression" => "quantityOrdered * priceEach",
                            "alias" => "Order Cost",
                            "type" => "number",
                            "decimal" => 2,
                            "prefix" => "$",
                        ]
                    ),
                    "products" => array(
                        "{meta}" => [
                            "alias" => "Table Products"
                        ],
                        "productCode" => array(
                            "alias" => "Product Code"
                        ),
                        "productName" => array(
                            // "alias" => "Product Name"
                        ),
                    )
                ],
                "relations" => [
                    ["orders.customerNumber", "leftjoin", "customers.customerNumber"],
                    ["orders.orderNumber", "join", "orderdetails.orderNumber"],
                    ["orderdetails.productCode", "leftjoin", "products.productCode"],
                ],
            ),
            "separator" => "."
        ];
    }

    function settings()
    {
        return array(
            "dataSources" => array(
                "automaker" => array(
                    "connectionString" => "mysql:host=localhost;dbname=automaker",
                    "username" => "root",
                    "password" => "",
                    "charset" => "utf8"
                ),
                'mysql' => [
                    'host' => 'localhost',
                    'username' => 'root',
                    'password' => '',
                    'dbname' => 'automaker',
                    'class' => '\koolreport\datasources\MySQLDataSource',
                ],
            )
        );
    }   
    
    protected function setup()
    {
        $params = Util::get($this->queryParams, 'visualquery1');
        // echo "params = "; Util::prettyPrint($params);
        $qb = $this->paramsToQueryBuilder($params);
        // $arr = $qb->toArray();
        // echo "qb array="; Util::prettyPrint($arr);
        $this->query = $params ? 
            $qb->toMySQL() : "select * from customers where 1=0";
        $this->paramQuery = $params ? 
        // $qb->toMySQL(['useSQLParams' => "question"]) : "select * from customers where 1=0";
            $qb->toMySQL(['useSQLParams' => "name"]) : "select * from customers where 1=0";
        $this->sqlParams = $qb->getSQLParams();
        // echo "paramQuery="; echo $this->paramQuery; echo "<br>";
        // Util::prettyPrint($this->sqlParams);

        $this
            ->src('automaker')
            // ->query($this->query)
            ->query($this->paramQuery)
            ->params($this->sqlParams)
            ->pipe(new \koolreport\processes\ColumnMeta([
                "Order Number" => [
                    "type" => "string"
                ],
                "orderMonth" => [
                    "type" => "string"
                ],
            ]))
            ->pipe($this->dataStore('vqDS'));
    } 

}

my view file.

   <?php
    // use \koolreport\widgets\koolphp\Table;
    // use \koolreport\widgets\google\ColumnChart;
    // use \koolreport\widgets\google\BarChart;
    
    use \koolreport\visualQuery\VisualQuery;
    use \koolreport\datagrid\DataTables;

  ?>
  <html>
    <head>
        <title>KoolReport visual query</title>
    </head>
    <body>
        <form method="post">
    <div class="report-content">
        <div class="text-center">
            <h1>VisualQuery</h1>
            <p class="lead">
            The basic working of VisualQuery
            </p>
        </div> 
        <?php
        \koolreport\visualquery\VisualQuery::create(array(
            "name" => "visualquery1",
            "themeBase" => "bs4",
            "schema" => "salesSchema",
            "defaultValue" => [
                "selectDistinct" => false,
                "selectTables" => [
                    "orders",
                    "orderdetails",
                    "products",
                ],
                "selectFields" => [
                    "products.productName",
                ],
                "filters" => [
                    "(",
                    [
                        "field" => "orders.orderDay", 
                        "operator" => ">", 
                        "value1" => "2001-01-01", 
                        "value2" => "", 
                        "logic" => "and",
                        "toggle" => true,
                    ],
                    [
                        "field" => "products.productCode", 
                        "operator" => "nbtw", 
                        "value1" => "2", 
                        "value2" => "998", 
                        "logic" => "or",
                        "toggle" => true,
                    ],
                    ["products.productName", "<>", "a", "", "or", "toggle" => false],
                    ["products.productName", "nin", "a,b,c", "", "or"],
                    ["products.productName", "ctn", "a", "", "or"],
                    ")",
                ],
                "groups" => [
                    [
                        "field" => "orderdetails.cost", 
                        "aggregate" => "sum", 
                        "toggle" => true
                    ]
                ],
                "havings" => [
                    "(",
                    [
                        "field" => "sum(orderdetails.cost)", 
                        "operator" => ">", 
                        "value1" => "10000", 
                        "value2" => "", 
                        "logic" => "and",
                        "toggle" => true,
                    ],
                    ["products.productName", "<>", "a", "", "or", "toggle" => false],
                    ")",
                ],
                "sorts" => [
                    [
                        "field" => "sum(orderdetails.cost)", 
                        "direction" => "desc", 
                        "toggle" => true
                    ],
                    ["products.productName", "desc", "toggle" => false]
                ],
                "limit" => [
                    "offset" => 5,
                    "limit" => 10,
                    "toggle" => false,
                ]
            ],
            "activeTab" => "filters",
        ));
        ?>
        <button type='submit' class='btn btn-light' >Submit</button> 
        <style>
            pre {
                overflow-x: auto;
                white-space: pre-wrap;
                white-space: -moz-pre-wrap;
                white-space: -pre-wrap;
                white-space: -o-pre-wrap;
                word-wrap: break-word;
            }
        </style>
        <div style="margin: 30px; width:800px">
            <b>Select query:</b>
            <pre style="width:800px"><?php echo $this->queryStr; ?></pre>
            <b>Query with parameters:</b>
            <pre style="width:800px"><?php echo $this->paramQuery; ?></pre>
            <b>Parameters:</b>
            <?php \koolreport\core\Utility::prettyPrint($this->sqlParams); ?>
        </div>
        <?php
            // print_r($this->dataStore('vqDS')->meta());
            DataTables::create(array(
                "name" => "charttable1",
                "dataSource" => $this->dataStore('vqDS'),
                // "columns" => ["Quantity", "Product Name"],
                "options" => [
                    "paging" => true
                ]
            ));
        ?>
    </div>
    </form>
    </body>
    </html>

Shaurya Bajaj commented on Feb 4, 2022

Hello, I have request this for this query since 1 day I didn't get any response from your team side. kindly help me to understand what I am missing in my code.

Shaurya Bajaj commented on Feb 7, 2022

Hello Team, It's been more then 72 hours since I post my query. I should have get priory response within 24 hours as I am having pro version. You guys promised us for quick response while we were buying it. I would request you guys to respond me and help me with my query.

Sebastian Morales commented on Feb 7, 2022

Sorry for the delay. We had holidays in the past week. Pls replace this line:

$queryParams = Util::get($report->queryParams, $this->name);

with:

$queryParams = Util::get($this->queryParams, $this->name); // access property queryParams inside a report

or:

$report->run(); // report must be run before its queryParams is generated
$queryParams = Util::get($report->queryParams, $VisualQueryWidgetName); // you must know the report's VisualQuery name
Shaurya Bajaj commented on Feb 7, 2022

Hello @Sebastian Morales, Thank you so much for the response.

I have tried both the ways to implement it but still getting the same error. could you please suggest what to do now?

So far I have tried this both changing on koolreport/visualquery/Visualquery,

        $report = $this->getReport();
        $queryParams = Util::get($this->queryParams, $this->name);

       And 

        $report = $this->getReport();
        $report->run();
        $queryParams = Util::get($report->queryParams, $this->name);
Sebastian Morales commented on Feb 8, 2022

Pls try this:


        $report = $this->getReport();
        $report->run();
        echo "report->queryParams = "; print_r($report->queryParams); echo "<br>"; // print out the report's query params
        $queryParams = Util::get($report->queryParams, $visualQueryName); // use the report's visual query widget name instead of $this->name
Shaurya Bajaj commented on Feb 8, 2022

I have tried the code you have given and now its giving one additional error.

Change on koolreport/visualquery/VisualQuery.php file

    protected function onInit()
    {
        $themeBase = $this->getThemeBase();
        if (empty($themeBase)) $themeBase = 'bs3';
        $this->themeBase = $themeBase;
        // echo "themeBase={$this->themeBase}<br>";
        $this->name = Util::get($this->params, 'id', null);
        $this->name = Util::get($this->params, 'name', $this->name);

        // $report = $this->getReport();
        // $queryParams = Util::get($this->queryParams, $this->name);
         $report = $this->getReport();
        $report->run();
        echo "report->queryParams = "; print_r($report->queryParams); echo "<br>"; // print out the report's query params
        $queryParams = Util::get($report->queryParams, $visualQueryName); // use the report's visual query widget name instead of $this->name
        $this->value = $report->paramsToValue($queryParams);
        // echo "this->value = "; Util::prettyPrint($this->value);
        $this->defaultValue = Util::get($this->params, 'defaultValue');
        $this->activeTab = strtolower(Util::get($this->value, 'activeTab',
            Util::get($this->params, 'activeTab', 'tables')));
        // echo "this->activeTab = {$this->activeTab}<br>";
        $schema = Util::get($this->params, "schema");
        if (is_string($schema) && method_exists($report, 'defineSchemas')) {
            $schemas = $report->defineSchemas();
            $this->schema = Util::get($schemas, $schema);
            $this->separator = Util::get($schemas, "separator", ".");
        } else if (is_array($schema)) {
            // $this->schema = $schema;
        }
        if (isset($this->value['schema'])) {
            if (json_decode($this->value['schema'], true) != $this->schema) {
                throw new \Exception("Schema not correct");
            }
        }
        list($this->tables, $this->allFields, $this->tableLinks) =
            $report->vqHelper->getFieldsAndLinks($this->schema);
    }

out put of your suggested code :

 VisualQuery
The basic working of VisualQuery

report->queryParams =

Errors visible :

A PHP Error was encountered
Severity: Notice

Message: Undefined property: koolreport\core\WidgetContainer::$queryParams

Filename: visualquery/VisualQuery.php

Line Number: 88

Backtrace:

File: C:\wamp64\www\myapplication\assets\koolreport\visualquery\VisualQuery.php
Line: 88
Function: _error_handler

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 157
Function: onInit

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 758
Function: __construct

File: C:\wamp64\www\myapplication\application\modules\reports\views\graphical_visual_query.php
Line: 23
Function: create
A PHP Error was encountered
Severity: Notice

Message: Undefined property: koolreport\core\WidgetContainer::$queryParams

Filename: visualquery/VisualQuery.php

Line Number: 89

Backtrace:

File: C:\wamp64\www\myapplication\assets\koolreport\visualquery\VisualQuery.php
Line: 89
Function: _error_handler

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 157
Function: onInit

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 758
Function: __construct

File: C:\wamp64\www\myapplication\application\modules\reports\views\graphical_visual_query.php
Line: 23
Function: create
A PHP Error was encountered
Severity: Notice

Message: Undefined variable: visualQueryName

Filename: visualquery/VisualQuery.php

Line Number: 89

Backtrace:

File: C:\wamp64\www\myapplication\assets\koolreport\visualquery\VisualQuery.php
Line: 89
Function: _error_handler

File: C:\wamp64\www\myapplication\koolreport\core\src\core\Widget.php
Line: 157
Function: onInit

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 758
Function: __construct

File: C:\wamp64\www\myapplication\application\modules\reports\views\graphical_visual_query.php
Line: 23
Function: create
Sebastian Morales commented on Feb 8, 2022

Can you pls post the code for your getReport() method?

Shaurya Bajaj commented on Feb 8, 2022

it is define on many screen I am posting all..

On myapplication/assets/koolreport/core/src/core/widget.php

/**
     * Get the report that holds this widget
     * 
     * @return KoolReport The report that holds this widget
     */
    public function getReport()
    {
        return $this->report;
    }

On myapplication/assets/koolreport/core/src/core/theme.php

/**
     * Return report that containing this theme
     * 
     * @return KoolReport Report object containing this theme
     */
    protected function getReport()
    {
        return $this->report;
    }

On myapplication/assets/koolreport/core/src/core/node.php

/**
     * Get the report that holds this node
     * 
     * @return KoolReport The report that holds this node
     */
    public function getReport()
    {
        if (isset($this->sources[0])) {
            return $this->sources[0]->getReport();
        }
        return null;
    }

On myapplication/assets/koolreport/core/src/core/datasource.php

/**
     * Get report object
     * 
     * Return the report object that contains this datasource
     * 
     * @return KoolReport Report object that contains this datasource
     */
    public function getReport()
    {
        return $this->report;
    }
Sebastian Morales commented on Feb 8, 2022

Oh, why did you edit/insert your code inside visualquery/VisualQuery.php? Pls remove all of your edit, run your report and let us know if there's any error. If there is, post the error message and your report code (not VisualQuery.php code).

Shaurya Bajaj commented on Feb 8, 2022

Re-set code inside visualquery/VisualQuery.php

Error and visible page are as below .

VisualQuery
The basic working of VisualQuery

A PHP Error was encountered
Severity: Notice

Message: Undefined property: koolreport\core\WidgetContainer::$queryParams

Filename: visualquery/VisualQuery.php

Line Number: 85

Backtrace:

File: C:\wamp64\www\myapplication\assets\koolreport\visualquery\VisualQuery.php
Line: 85
Function: _error_handler

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 157
Function: onInit

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 758
Function: __construct

File: C:\wamp64\www\myapplication\application\modules\reports\views\graphical_visual_query.php
Line: 23
Function: create
An uncaught Exception was encountered
Type: Error

Message: Call to undefined method koolreport\core\WidgetContainer::paramsToValue()

Filename: C:\wamp64\www\myapplication\assets\koolreport\visualquery\VisualQuery.php

Line Number: 86

Backtrace:

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 157
Function: onInit

File: C:\wamp64\www\myapplication\assets\koolreport\core\src\core\Widget.php
Line: 758
Function: __construct

File: C:\wamp64\www\myapplication\application\modules\reports\views\graphical_visual_query.php
Line: 23
Function: create

report code are as follow.. on reports.php

class Reports extends Admin_Controller
{ 
    public function visual_query()
    {
        $data['report'] = new MyReport;
        $this->layout->set($data);
        $this->layout->buffer('content', 'reports/graphical_visual_query');
        $this->layout->render();   
    }
}

require_once APPPATH.'../assets/koolreport/core/autoload.php';

use \koolreport\core\Utility as Util;
class MyReport extends \koolreport\KoolReport
{
    use \koolreport\visualquery\Bindable;

     public function defineSchemas()
    {
        return [
            "salesSchema" => array(
                "tables" => [
                    "customers" => array(
                        "{meta}" => [
                            "alias" => "Table Customers"
                        ],
                        "customerNumber" => array(
                            "alias" => "Customer Number",
                        ),
                        "customerName" => array(
                            "alias" => "Customer Name",
                        ),
                    ),
                    "orders" => array(
                        "{meta}" => [
                            "alias" => "Table Orders"
                        ],
                        "orderNumber" => array(
                            "alias" => "Order Number"
                        ),
                        "orderDay" => array(
                            "alias" => "Order Day",
                            "expression" => "date(orderDate)",
                            "type" => "date",
                        ),
                        "orderDate" => array(
                            "alias" => "Order Date",
                            "type" => "datetime",
                        ),
                        "orderMonth" => [
                            "expression" => "month(orderDate)",
                            "type" => "number",
                        ]
                        // "customerNumber"=>array(
                        //    "alias"=>"Customer Number"
                        // )
                    ),
                    "orderdetails" => array(
                        "{meta}" => [
                            "alias" => "Order Details"
                        ],
                        // "orderNumber"=>array(
                        //     "alias"=>"Order Number"
                        // ),
                        "quantityOrdered" => array(
                            "alias" => "Quantity",
                            "type" => "number",
                        ),
                        "priceEach" => array(
                            "alias" => "Price Each",
                            "type" => "number",
                            "decimal" => 2,
                            "prefix" => "$",
                        ),
                        // "productCode"=>array(
                        //     "alias"=>"Product Code"
                        // ),
                        "cost" => [
                            // "expression" => "orderdetails.quantityOrdered * orderdetails.priceEach",
                            "expression" => "quantityOrdered * priceEach",
                            "alias" => "Order Cost",
                            "type" => "number",
                            "decimal" => 2,
                            "prefix" => "$",
                        ]
                    ),
                    "products" => array(
                        "{meta}" => [
                            "alias" => "Table Products"
                        ],
                        "productCode" => array(
                            "alias" => "Product Code"
                        ),
                        "productName" => array(
                            // "alias" => "Product Name"
                        ),
                    )
                ],
                "relations" => [
                    ["orders.customerNumber", "leftjoin", "customers.customerNumber"],
                    ["orders.orderNumber", "join", "orderdetails.orderNumber"],
                    ["orderdetails.productCode", "leftjoin", "products.productCode"],
                ],
            ),
            "separator" => "."
        ];
    }

    function settings()
    {
        return array(
            "dataSources" => array(
                "automaker" => array(
                    "connectionString" => "mysql:host=localhost;dbname=automaker",
                    "username" => "root",
                    "password" => "",
                    "charset" => "utf8"
                ),
                'mysql' => [
                    'host' => 'localhost',
                    'username' => 'root',
                    'password' => '',
                    'dbname' => 'automaker',
                    'class' => '\koolreport\datasources\MySQLDataSource',
                ],
            )
        );
    }   
    
    protected function setup()
    {
        $params = Util::get($this->queryParams, 'visualquery1');
        $qb = $this->paramsToQueryBuilder($params);
        $this->query = $params ? $qb->toMySQL() : "select * from customers where 1=0";
        $this->paramQuery = $params ? $qb->toMySQL(['useSQLParams' => "name"]) : "select * from customers where 1=0";
        $this->sqlParams = $qb->getSQLParams();

        $this
            ->src('automaker')
            ->query($this->paramQuery)
            ->params($this->sqlParams)
            ->pipe(new \koolreport\processes\ColumnMeta([
                "Order Number" => [
                    "type" => "string"
                ],
                "orderMonth" => [
                    "type" => "string"
                ],
            ]))
            ->pipe($this->dataStore('vqDS'));
    } 
}

On view page (graphical_visual_query.php)

<?php 

use \koolreport\visualQuery\VisualQuery;
use \koolreport\datagrid\DataTables;

?>

<html>
<head>
    <title>KoolReport visual query</title>
</head>
<body>
    <form method="post">
<div class="report-content">
    <div class="text-center">
        <h1>VisualQuery</h1>
        <p class="lead">
        The basic working of VisualQuery
        </p>
    </div> 
    <?php
    \koolreport\visualquery\VisualQuery::create(array(
        "name" => "visualquery1",
        "themeBase" => "bs4",
        "schema" => "salesSchema",
        "defaultValue" => [
            "selectDistinct" => false,
            "selectTables" => [
                "orders",
                "orderdetails",
                "products",
            ],
            "selectFields" => [
                "products.productName",
            ],
            "filters" => [
                "(",
                [
                    "field" => "orders.orderDay", 
                    "operator" => ">", 
                    "value1" => "2001-01-01", 
                    "value2" => "", 
                    "logic" => "and",
                    "toggle" => true,
                ],
                [
                    "field" => "products.productCode", 
                    "operator" => "nbtw", 
                    "value1" => "2", 
                    "value2" => "998", 
                    "logic" => "or",
                    "toggle" => true,
                ],
                ["products.productName", "<>", "a", "", "or", "toggle" => false],
                ["products.productName", "nin", "a,b,c", "", "or"],
                ["products.productName", "ctn", "a", "", "or"],
                ")",
            ],
            "groups" => [
                [
                    "field" => "orderdetails.cost", 
                    "aggregate" => "sum", 
                    "toggle" => true
                ]
            ],
            "havings" => [
                "(",
                [
                    "field" => "sum(orderdetails.cost)", 
                    "operator" => ">", 
                    "value1" => "10000", 
                    "value2" => "", 
                    "logic" => "and",
                    "toggle" => true,
                ],
                ["products.productName", "<>", "a", "", "or", "toggle" => false],
                ")",
            ],
            "sorts" => [
                [
                    "field" => "sum(orderdetails.cost)", 
                    "direction" => "desc", 
                    "toggle" => true
                ],
                ["products.productName", "desc", "toggle" => false]
            ],
            "limit" => [
                "offset" => 5,
                "limit" => 10,
                "toggle" => false,
            ]
        ],
        "activeTab" => "filters",
    ));
    ?>
    <button type='submit' class='btn btn-light' >Submit</button> 
    <style>
        pre {
            overflow-x: auto;
            white-space: pre-wrap;
            white-space: -moz-pre-wrap;
            white-space: -pre-wrap;
            white-space: -o-pre-wrap;
            word-wrap: break-word;
        }
    </style>
    <div style="margin: 30px; width:800px">
        <b>Select query:</b>
        <pre style="width:800px"><?php echo $this->queryStr; ?></pre>
        <b>Query with parameters:</b>
        <pre style="width:800px"><?php echo $this->paramQuery; ?></pre>
        <b>Parameters:</b>
        <?php \koolreport\core\Utility::prettyPrint($this->sqlParams); ?>
    </div>
    <?php
        // print_r($this->dataStore('vqDS')->meta());
        DataTables::create(array(
            "name" => "charttable1",
            "dataSource" => $this->dataStore('vqDS'),
            // "columns" => ["Quantity", "Product Name"],
            "options" => [
                "paging" => true
            ]
        ));
    ?>
</div>
</form>
</body>
</html>
Sebastian Morales commented on Feb 8, 2022

Pls open the file visualquery/VisualQuery.php and replace this line:

    $report = $this->getReport();

with these ones:

    $report = $this->getReport();
    echo "report class = "; echo get_class($report); echo "<br>";

Then run your report and let us know the output of the echoed line.

Shaurya Bajaj commented on Feb 8, 2022

this is the output line and errors which I sent before is still there.

report class = koolreport\core\WidgetContainer
Sebastian Morales commented on Feb 8, 2022

Can you let us know which version of PHP you are using and whether global variable is enabled? If global variable is disabled pls enable it.

Shaurya Bajaj commented on Feb 8, 2022

I am using : PHP 7.2.33

I have put code inside myapplication/asset folder where it be access easily.

let me know if you want me to move to any other folder. Asset is the folder where my application's css and js is define. It can be access in all over the project.

Shaurya Bajaj commented on Feb 8, 2022

Also Global variables are enabled.

David Winterburn commented on Feb 8, 2022

Did you manipulate global variable $GLOBALS any where in your project?

Shaurya Bajaj commented on Feb 8, 2022

Hello David,

We use a lot of global variables throughout our project. If you have specific key names for global variable we need to look for, it would be easier to identify.

Sebastian Morales commented on Feb 8, 2022

We use only one global key $GLOBALS["__ACTIVE_KOOLREPORT__"], which is used to get the report object of a widget. If you happen to use this key or clear $GLOBALS anywhere pls keep this key value for KoolReport.

Shaurya Bajaj commented on Feb 9, 2022

Issue is resolved. Thanks for your support.

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

VisualQuery