lundi 8 janvier 2024

Laravel 5.3, empty() is treating a zero value as empty in a query

In my Laravel project (version 5.3), I'm sending a param in a URL:

&container=0

But by the time it gets into the PHP function that creates an SQL query, it treats the zero as empty and satisfies the empty string portion of this line:

$containerCL = empty($container) ? '' : "AND SHPTABLE.CNT IN (".implode(',',$container).")";

I do want to send an empty string into the query if no option is chosen for this, but in this case, I need to send the zero value as we have some records identified by that being the actual value. How can I let this catch empty parameters but still use zero as an actual value for the query?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/ChndkjZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire