diff --git a/docs/development/legacy/database/index.md b/docs/development/legacy/database/index.md index 3cd39c789..fc19d93b1 100755 --- a/docs/development/legacy/database/index.md +++ b/docs/development/legacy/database/index.md @@ -10,3 +10,14 @@ # Database Driver ExpressionEngine comes with a full-featured and very fast abstracted database driver that supports both traditional structures and Active Record patterns. The database functions offer clear, simple syntax. + +## Whole-word Regular Expressions + +Use `ee()->db->word_boundary_regex()` when building a database `REGEXP` query that should match a term as a whole word: + +``` +$term = ee()->db->word_boundary_regex('cat'); +$sql = 'field_id_1 REGEXP "' . ee()->db->escape_str($term) . '"'; +``` + +This helper returns a pattern that is compatible with the active database. MySQL 8.0.4 and newer use ICU regular expressions and require different word-boundary handling than older MySQL versions and MariaDB, which use the legacy Spencer regular-expression markers.