function sql_like_expression($expression)
{
$expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression);
$expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression);
return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\'');
}
I am not sure what this function is doing. From what I am seeing, i think it replaces _ with \_ though I am unsure if thats exactly whats going on. Why is it array‘s and what do the % mean?
Cheers.
In a SQL LIKE expression, the
_means any single character, and%means any characters.%and_characters to remove their special meaning (adding a\before them removes their special meaning)%and_characters that was preceeded by a NULL byte (char(0)).The use of arrays in str_replace allows to do multiple replacements at once.