tc-php-mvc-core icon indicating copy to clipboard operation
tc-php-mvc-core copied to clipboard

sql statement error fixed

Open pathak404 opened this issue 3 years ago • 0 comments

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... 😊

pathak404 avatar Oct 24 '22 09:10 pathak404