Skip to content

Commit afdd8c3

Browse files
committed
Fix #719
1 parent 28fd6ce commit afdd8c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,9 @@ protected function compileWhereBasic($where)
905905
// Replace like with a Regex instance.
906906
if ($operator == 'like') {
907907
$operator = '=';
908-
$regex = str_replace('%', '', $value);
908+
909+
// Convert to regular expression.
910+
$regex = preg_replace('#(^|[^\\\])%#', '$1.*', preg_quote($value));
909911

910912
// Convert like to regular expression.
911913
if (! starts_with($value, '%')) {

0 commit comments

Comments
 (0)