563 | | $query = str_replace("'%s'", '%s', $query); // in case someone mistakenly already singlequoted it |
564 | | $query = str_replace('"%s"', '%s', $query); // doublequote unquoting |
565 | | $query = str_replace('%s', "'%s'", $query); // quote the strings |
| 563 | // allow literal % to be entered as such |
| 564 | $query = str_replace('%', '%%', $query); |
| 565 | // leave things such as LIKE '%%stuff' or 'some %%stuff' untouched |
| 566 | // but catch mistakingly quoted strings such as '%%s' |
| 567 | $query = preg_replace("/(^|\s)(['\"]?)%%s\\2(\s|$)/", "$1'%d'$3", $query); |
| 568 | $query = preg_replace("/(^|\s)(['\"]?)%%d\\2(\s|$)/", "$1%d$3", $query); |