#2361 - Add support for abstracting some basic SQL functions

Identifier #2361
Issue type Feature request or suggestion
Title Add support for abstracting some basic SQL functions
Status Completed
Handling member Chris Graham
Addon core_database_drivers
Description SQL functions are ill-defined or not defined at all in SQL standards. Currently we sometimes add in a little extra functionality/performance for mysql-only, by using some functions behind guards. Here are the ones we may use...

CONCAT
REPLACE
REVERSE
SUBSTR
LENGTH
UNIX_TIMESTAMP
RAND
IFNULL
GREATEST
MOD

Allow us to do like...

$GLOBALS['SITE_DB']->query('SELECT * FROM foo WHERE ' . $GLOBALS['SITE_DB']->sql_cleanup('SUBSTR(bar,0,1)=\'something\''));

It's a bit ugly, but at least it then allows database drivers to override sql_cleanup and fix SQL that won't work on that driver.

An alternative would be to implement a full SQL parser, but that's a performance issue and a lot of overhead in the code.
Steps to reproduce

Funded? No
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".

Rating

Unrated