M:n Relation with index 0 not works

Hi
after several e-Mails to Scriptcase Support i try here to get this bug solved here:
I have an m:n relationship where the index of the lookup can be the number 0 (not null). In this case, scriptcase not update or write the relation. And i found also the reason. In my application on nm_acessa_banco() they check for

if (!empty($mydevicetypelnkx)

But if mydevicetypelnkx is zero, then the php function empty() will return false and the underlaying code will not be executed. So the correct code should be:

if (!empty($mydevicetypelnkx) OR ($mydevicetypelnkx==0))

I hope they fix that soon. I reported this bug including solution allready one month ago. I am really angry, when they not fix their own bugs (before the last update, everything works fine, also with 0 in index). Is it like that, i can not recommend Scriptcase for any productional use… and i am customer since 2014… sad!

In the SQL Statement can you replace the lookup value for 0 to NULL

Ex. SELECT IF (lookup = 0 , NULL, lookup) as lookup, value FROM table ORDER BY value

And why i have to do that? 0 (the number zero) is the correct link value for this m:n relation.

What about

SELECT IF (lookup = 0 , ‘00’, lookup) as lookup, value FROM table ORDER BY value

Same, the php function empty() will always return false when value is 0 (https://www.php.net/manual/en/function.empty.php).

Scriptcase has to fix that, because the use of empty() in this case is not possible, because the number 0 mean not “empty” in the context they use this function. And again: Before the last update, it works without problems.

But thank’s anyway for the answer.

try it with ‘00’, I have tested it and it work

And I do agree that it has to be fix by SC

Thank’s for your help, with your select statement, the record will be written. But: In de display, it shows me not the name in my linked table, it shows me 0… because string 00 does not match number 0. So i have to wait for SC to fix it. And again: When i use SC in productive systems and then they deployed a bug, i expect that they fix it soon after report or at least they answer e-Mails. None of them happen for over 1 month now.

Same, the php function empty() will always return false when value is 0 (https://www.php.net/manual/en/function.empty.php 1).

@stephanw

empty() will return true when value is 0.

as per your link: “Returns false if var exists and has a non-empty, non-zero value,”

empty(0) results in TRUE.
Can check here: https://sandbox.onlinephpfunctions.com/

SC checks if not empty($value), with $value=0, the code below the “if”-statement will not be executed.

@stephanw
you just wrote “empty(0) results in TRUE”.
this is correct

but in one of your previous post you wrote :
“the php function empty() will always return false when value is 0”
that’s what i was pointing out it’s not correct.

based on the context, maybe you meant that “the php function !empty() will always return false when value is 0”

Thank’s for this input, that’s correct. In the code of Scriptcase they use ! to invert the result :slight_smile:

So, now i hope, they start to work soon on this…