thecodeholic / tc-php-mvc-core

103 stars 30 forks source link

sql statement error fixed #10

Open pathak404 opened 1 year ago

pathak404 commented 1 year ago

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