File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -389,8 +389,49 @@ protected function _escapeString(string $str): string
389389
390390 //--------------------------------------------------------------------
391391
392+ /**
393+ * Escape Like String Direct
394+ * There are a few instances where MySQLi queries cannot take the
395+ * additional "ESCAPE x" parameter for specifying the escape character
396+ * in "LIKE" strings, and this handles those directly with a backslash.
397+ *
398+ * @param string|string[] $str Input string
399+ * @return string|string[]
400+ */
401+ public function escapeLikeStringDirect ($ str )
402+ {
403+ if (is_array ($ str ))
404+ {
405+ foreach ($ str as $ key => $ val )
406+ {
407+ $ str [$ key ] = $ this ->escapeLikeStringDirect ($ val );
408+ }
409+
410+ return $ str ;
411+ }
412+
413+ $ str = $ this ->_escapeString ($ str );
414+
415+ // Escape LIKE condition wildcards
416+ return str_replace ([
417+ $ this ->likeEscapeChar ,
418+ '% ' ,
419+ '_ ' ,
420+ ], [
421+ '\\' . $ this ->likeEscapeChar ,
422+ '\\' . '% ' ,
423+ '\\' . '_ ' ,
424+ ], $ str
425+ );
426+
427+ return $ str ;
428+ }
429+
430+ //--------------------------------------------------------------------
431+
392432 /**
393433 * Generates the SQL for listing tables in a platform-dependent manner.
434+ * Uses escapeLikeStringDirect().
394435 *
395436 * @param boolean $prefixLimit
396437 *
@@ -402,7 +443,7 @@ protected function _listTables(bool $prefixLimit = false): string
402443
403444 if ($ prefixLimit !== false && $ this ->DBPrefix !== '' )
404445 {
405- return $ sql . " LIKE ' " . $ this ->escapeLikeString ($ this ->DBPrefix ) . "%' " ;
446+ return $ sql . " LIKE ' " . $ this ->escapeLikeStringDirect ($ this ->DBPrefix ) . "%' " ;
406447 }
407448
408449 return $ sql ;
You can’t perform that action at this time.
0 commit comments