Closed Brewal closed 5 years ago
Hi Brewal,
Thanks for the report. This is def an oversight that would cause some seriously hard to debug issues. I have updated the 2.x branch with your suggested update and replaced a few more (less critical) rtrim calls with preg_replace. Changes are covered here: https://github.com/FaaPz/PDO/commit/2c06e83d337a4ef03744305993727f151bf443e1
https://github.com/FaaPz/Slim-PDO/blob/2eaaae8c5fbfeba832bf3c8fa88b1780e23554ee/src/PDO/Clause/WhereClause.php#L231
ltrim
should not be used here.ltrim
removes any of the characters in the second parameter starting from left until it encounters another character. So if you have a field starting with capital 'A', 'N' or 'D', this first char will be removed.preg_replace
should be used instead to remove the first' AND '
:return ' WHERE ' . preg_replace('/^(\sAND\s)/', '', implode('', $args));