File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
lib/Doctrine/DBAL/Platforms Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -3578,4 +3578,22 @@ public function getStringLiteralQuoteCharacter()
3578
3578
{
3579
3579
return "' " ;
3580
3580
}
3581
+
3582
+ /**
3583
+ * Escapes metacharacters in a string intended to be used with a LIKE
3584
+ * operator.
3585
+ */
3586
+ public function escapeStringForLike (string $ untrustedString ): string
3587
+ {
3588
+ $ replacePairs = [];
3589
+ $ escapeChar = $ this ->getLikeEscapeChar ();
3590
+ foreach ($ this ->getLikeMetaCharacters () as $ metaChar ) {
3591
+ $ replacePairs [$ metaCharacter ] = $ escapeChar .$ metaChar ;
3592
+ }
3593
+
3594
+ return strtr ($ untrusted , $ replacePairs );
3595
+ }
3596
+
3597
+ abstract protected function getLikeEscapeChar ();
3598
+ abstract protected function getLikeMetaCharacters ();
3581
3599
}
You can’t perform that action at this time.
0 commit comments