is true really an integer in cfqueryparam???
if you use the literal word "true" as the value for integer type cfqueryparam, this executes the query with an integer value of "1".
if you use the literal word "true" as the value for integer type cfqueryparam, this executes the query with an integer value of "1".
I am sorry to repeat this, but feel I have to for the sake of rigour. In your code example, ColdFusion is not converting type. You have specified the type, namely, integer.
If you tell ColdFusion that the datatype of a variable is "integer", and you then pass it the value True/False, then ColdFusion will interpret the value to be 1/0 implicitly. In other words, in ColdFusion,
integer value of True is 1
and
integer value of False is 0
ColdFusion is not the only language that has this. The same thing happens in Lucee, PHP, C / C++, JavaScript and Python.
That said, the test
isNumeric(url.company_id) ? url.company_id : 0
is not an accurate validation test for integers,. This test would give 3.14 a thumbs-up, which is incorrect.
Dave's suggestion,
isValid("integer",url.company_id) ? url.company_id : 0
is an accurate validation test for integers.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.