tc-php-mvc-core
tc-php-mvc-core copied to clipboard
sql statement error fixed
Error explanation:
The line implode("AND", array_map(fn($attr) => "$attr = :$attr", $attributes));
will produce an error "Invalid parameter number: parameter was not defined"
because if the item in the array $attributes is greater than 1 then it will separate them by AND but there is no gap between them.
eg: attr1 = :attr1ANDattr2 = :attr2
so it will produce an error.
Fix:
By adding a single space character before and after the separator AND
implode(" AND ", array_map(fn($attr) => "$attr = :$attr", $attributes));
will produce:
attr1 = :attr1 AND attr2 = :attr2
this is the right syntax... 😊