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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With