php-sql-query-builder icon indicating copy to clipboard operation
php-sql-query-builder copied to clipboard

PHP 7.0 - Update Query - setValues() - empty string value filtered out

Open evanirla opened this issue 8 years ago • 3 comments

When calling the setValues function, if the array contains a key/value pair with an empty string value, the key/value pair will be filtered out.

Looking at the code, there is an issue with the array_filter call where an empty string value is treated as false.

evanirla avatar Dec 30 '17 20:12 evanirla

I just did a test, using the isset() function seems to work.

evanirla avatar Dec 30 '17 20:12 evanirla

great @evanirla , but yes PHP does sees empty string as false when its used in a conditional statement, so will be good to avoid passing empty strings

marcus-hiles avatar Mar 29 '19 11:03 marcus-hiles

Just hit this issue myself on 1.8.0. While PHP treats an empty string as false, in this context the outcome does not represent the intended behaviour and blocks a number of valid (and common) use cases. null, "", false, and any other falsey values should valid input for a field.

Silic0nS0ldier avatar Jul 14 '20 02:07 Silic0nS0ldier