KoolReport's Forum

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

Using instant package >> Error in querybuilder #229

Open bysystem opened this topic on on Mar 9, 2018 - 12 comments

bysystem commented on Mar 9, 2018

Dear support team,

Just downloaded the instant package and querybuilder and my index.php file is like your example as follows:

<?php
//Index.php
require_once "koolreport/autoload.php";

use \koolreport\querybuilder\DB;
use \koolreport\widgets\koolphp\Table;

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\instant\SinglePage;
    use \koolreport\clients\Bootstrap;
    function settings()
    {
        return array(
            "dataSources"=>array(
                "automaker"=>array(
                    'connectionString'=>'mysql:host=localhost;dbname=nrp',
                    'username'=>'root',
                    'password'=>'',
                    'charset'=>'utf8'
                ),
            )
        );
    }

    function setup()
    {
        $this->src('automaker')->query(
            DB::table("set_items")->select("item_id","item_name","item_desc","stock_soll", "list_price","stock_ist", "order","remarks","set")->toMySQL()
        )
        ->pipe($this->dataStore("mydata"));
    }
}

$report = new MyReport;
$report->start();
?>

<html>
    <head>
        <title>SET-Produkte</title>
    </head>
    <body>
        <h1>Beschreibung</h1>
        <?php
        Table::create(array(
            "dataSource"=>$report->dataStore('mydata')
        ));
        ?>
    </body>
</html>

<?php $report->end(); ?>

When I try to call the index.php I get the following error message:

Parse error: syntax error, unexpected 'as' (T_AS), expecting identifier (T_STRING) in C:\xampp\htdocs\nrp_sets\koolreport\packages\querybuilder\Query.php on line 107

Any syntax error in my code above?

Kind regards,

KoolReport commented on Mar 9, 2018

Could you please help to go to line 107 of the Query.php in querybuilder folder and change the function name from "as" to "alias". It seems that "as" is a keyword of PHP and it may confuse php in parsing. We use PHP 7 to write this library so it seems that later version of php accepting "as" as a function.

bysystem commented on Mar 12, 2018

Thx for your hint. Just changed in the line 107 of /querybuilder/Query.php from

"public function as($name)"

to

"public function alias($name)".

But now I get the following error message:

Parse error: syntax error, unexpected 'switch' (T_SWITCH), expecting identifier (T_STRING) in C:\xampp\htdocs\nrp_sets\koolreport\packages\querybuilder\Query.php on line 560

Any idea what could be the reason?

Kind regards,

KoolReport commented on Mar 12, 2018

That's bad. It is the same issue, so you change the switch() function name to another name like "branch()".

bysystem commented on Mar 12, 2018

OK, I guess we are now closer to the final solution:

After changing the line 560 of /querybuilder/Query.php from

public function switch($value,$array) to public function branch($value,$array)

I get now an error message in the file /querybuilder/SQL.php line 90:

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\nrp_sets\koolreport\packages\querybuilder\SQL.php on line 90

KoolReport commented on Mar 12, 2018

I see, please go the SQL.php (line 90), change the Query::class to this string "koolreport\querybuilder\Query"

bysystem commented on Mar 12, 2018

OK, changed from else if(is_a($condition,Query::class)) to else if(is_a($condition,koolreport\querybuilder\Query))

No there is a parse error in \koolreport\core\Widget.php on line 246

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\nrp_sets\koolreport\core\Widget.php on line 246

KoolReport commented on Mar 12, 2018

It should be:

else if(is_a($condition,"koolreport\querybuilder\Query"))

covering the class name in quote.

bysystem commented on Mar 12, 2018

Oh, sorry, you're right! Just changed it to:

else if(is_a($condition,"koolreport\querybuilder\Query"))

Now I get another parse error coming back to the Widget.php on line 246:

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\nrp_sets\koolreport\core\Widget.php on line 246

KoolReport commented on Mar 12, 2018

From the line 246 to line 253, you change to this code:

else if(is_a($dataSource,'koolreport\core\DataStore'))
{
	$this->dataStore = $dataSource;
}
else if(is_a($dataSource,'koolreport\core\DataSource')||is_a($dataSource,'koolreport\core\Process'))
{
	$this->dataStore = $this->onFurtherProcessRequest($dataSource)->pipe(new DataStore($this->getReport()));
}
KoolReport commented on Mar 12, 2018

We are sorry for the incidence, we have use feature of later PHP, the ::class was introduced in PHP 5.5 so older PHP does not recognize it. In the future, it would be great if you could upgrade PHP to 5.6 or better 7.0. PHP 7 is very fast.

bysystem commented on Mar 12, 2018

Great job! It work's fine now!

Thx a lot for your effort!

KoolReport commented on Mar 12, 2018

Thank you for your patience. And yes, we will keep this change for next release so you will not have this problem again.

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

QueryBuilder