ThingEngineer / PHP-MySQLi-Database-Class

Wrapper for a PHP MySQL class, which utilizes MySQLi and prepared statements.
Other
3.29k stars 1.35k forks source link

groupBy DATE_FORMAT() removes quotes #941

Open michinamibia opened 3 years ago

michinamibia commented 3 years ago

Using the grouBy function like this $db->groupBy("DATE_FORMAT(ymd, '%Y-%m')"); causes a fatal error:

Fatal error: Uncaught Exception: Unknown column 'Y' in 'group statement' query: SELECT ... DATE_FORMAT(ymd, Y-m) ...

Comparing the orderBy filter with the groupBy filter it shows that the quotation mark get's stripped.

$orderByField = pregreplace("/[^ -a-z0-9.(),`*\'\"]+/i", '', $orderByField); $groupByField = pregreplace("/[^-a-z0-9.(),* <>=!\'\"]+/i", '', $groupByField);

I fixed it for my personal installation, but was wondering if there is a specific reason? If not a pull request could be made to make the preg_replace the same for both functions.

tcblaize commented 1 year ago

Any word on this?