[SR-Users] how can string "0" be equal to int 0?
Iñaki Baz Castillo
ibc at aliax.net
Fri Oct 15 22:15:21 CEST 2010
2010/10/15 Daniel-Constantin Mierla <miconda at gmail.com>:
>> Usually I get data from a DB table in which some fields are INT
>> (allowing NULL). Possible values are NULL or integers from 0 to N.
>> Trying to figure if the column has value 0 is a pain.
>
> Have you tried: if($var(x)==0) ?
Yes, that would work, but it's not what I need:
I retrieve a table column value via a DB query and store it in an AVP.
Such column can store NULL, 0, 1, 2 ... 8.
How can I check if the AVP has an integer value (including 0)?:
1) In case I retrieve 1...8 from the database:
- if $avp(column) => true
- if $avp(column) >=0 => true
2) In case I retrieve 0 or NULL from the database:
- if $avp(column) => false
- if $avp(column) >=0 => ERROR (invalid comparison)
So there is no way to determine if the retrieved value is *any*
integer (including 0), is there?
PS: I *strongly* hate the fact that 0 is threated as "false" or "non true", why?
Regards.
--
Iñaki Baz Castillo
<ibc at aliax.net>
More information about the sr-users
mailing list