[SOLVED]Bug in generatig a grid when sql statement contains a variable

Hello,

I have found a bug in V8 that was NOT present in V7.

To reproduce this bug using SC V8, please follow these steps:

  1. create a simple grid application using whatever sql statement you prefer.
    For the sake of this example I am using this trivial sql statement:

SELECT
MYFIELD
FROM
MYTABLE

  1. Generate and run the application.
    So far so good: it works (of course MYTABLE must exists with a field named MYFIELD)

  2. Now modify the sql statement, replacing the table name with a variable, like this:

SELECT
MYFIELD
FROM
[TABVAR]

  1. Generate and run the application.

  2. At run time you will be prompted to enter a value for variable TABVAR. Please enter MYTABLE as a value.
    You should get this error message:

Parse error: syntax error, unexpected ‘$_SESSION’ (T_VARIABLE), expecting identifier (T_STRING) in /opt/NetMake/v8/wwwroot/scriptcase/app/Test/TEST/index.php on line 540

  1. If you look at the generated code you see that variable $_SESSION has been prefixed with a \ (backslash), which causes a syntax error in the PHP parser.
    I have already opened a ticket and tried to explain this bug to the support team but with no success.
    They are not able to reproduce the bug. I guess we have difficulties in understanding each other.
    My portoguese is honestly zero and we have some issues in understanding each other using english.

Can you please confirm you can reproduce it ?

My hope is that someone fluent in portuguese can open this bug to the support team.

Thanks a lot.

Hello maxi,

Did you get any responce on you message? I have same problem and need to remove “” sign from compiled grid applications:

Parse error: syntax error, unexpected ‘$_SESSION’ (T_VARIABLE), expecting identifier (T_STRING) in /opt/NetMake/v8/wwwroot/scriptcase/app/AntiFraud_D108854002/SIP_Business_number/index.php on line 541

$this->nm_tabela = “number join user on number.userid=user.id and user.username=’” . $_SESSION[‘username’] . “’”;
^^^^
With best regards,

 Stanislav

Hello,

I was able to reproduce the issue. I will pass it on to our bugs/development team.

regards,
Bernhard Bernsmann

[QUOTE=Vikulov;30944]Hello maxi,

Did you get any responce on you message? I have same problem and need to remove “” sign from compiled grid applications:

Parse error: syntax error, unexpected ‘$_SESSION’ (T_VARIABLE), expecting identifier (T_STRING) in /opt/NetMake/v8/wwwroot/scriptcase/app/AntiFraud_D108854002/SIP_Business_number/index.php on line 541

$this->nm_tabela = “number join user on number.userid=user.id and user.username=’” . $_SESSION[‘username’] . “’”;
^^^^
With best regards,

 Stanislav[/QUOTE]

Hello Stanislav,
I have not received any response yet but there is a workardound that to me it’s better that the bug itself.
Use a feature I didn’t know about before experimenting against this bug: Variable for Table.

In the SQL from clause just leave the original table name ( MYTABLE ) without trying to replace it it with a variable.
Then fill the two fields below, called : Variable for Table.
I have attached a picture to explain better.

Please note that MYVAR in the field Variable for Table must entered WITHOUT square brackets and in the field just below it you must enter the original table name : MYTABLE.
Scriptcase will substitute, at run time, the content of MYVAR to the string MYTABLE.
You can set the content of MYVAR in an event or where you want to. I have personally set MYVAR in the onApplicationInit event.

screen.png

Hello,

This problem has been fixed. Please update your ScriptCase.