How to insert null inside database - Forum

Forum Navigation
You need to log in to create posts and topics.

How to insert null inside database

Hi all,

When I insert in my database using neoPhpExecSql "dbMT" "inserttour1" "[nID]::[aJ(0)]::[aJ(1)]::[aJ(2)]::[aJ(3)]::[aJ(4)]::[aJ(5)]" "", some [aJ] can be null ( ArrayAddItem [aJ] null  or  ArrayAddItem [aJ] "").

But the value inserted is not null but undefined ???
.

@phil78 I think it's not possible to send a "null" value from JavaScript to PHP. You can send an empty string instead and interpret it as null by setting the default field value to NULL.

Regards.

Thanks Luis,

Unfortunately this is the case now, the default value is null in the database, and the empty string returns undefined...

@phil78 a non existent variable returns "undefined", that's different that an empty string stored in an existent variable.
A variable dos not exist if you have never stored anything in there.
Regards.

javadrajabihakami has reacted to this post.
javadrajabihakami

What I found is that if the parameter is not defined, (neoPhpExecSql "dbMT" "inserttour1" "[nID]::[aJ(0)]::[aJ(1)]::::[aJ(3)]::[aJ(4)]::[aJ(5)]" "") we get an empty string ([aJ(2)] => ""), and if we do not pass the parameter (neoPhpExecSql "dbMT" "inserttour1" "[nID]::[aJ(0)]::[aJ(1)]::[aJ(3)]::[aJ(4)]" "") then we get a NULL  ([aJ(2)] and  [aJ(5)] => null),
which forces to arrange or multiply the request to have the optional parameters last.

So now it is clear for me. Thank you Luis

 

luishp has reacted to this post.
luishp

I have the same issue and initialize the variable with a setvar prior to send it to neoPhpExecSql solves the problem.

I think those useful tips and tricks must embedded to online help.