66
77package gdb
88
9+ import "github.com/gogf/gf/v2/util/gconv"
10+
911// WhereOrPrefix performs as WhereOr, but it adds prefix to each field in where statement.
1012// Eg:
1113// WhereOrPrefix("order", "status", "paid") => WHERE xxx OR (`order`.`status`='paid')
@@ -56,7 +58,8 @@ func (b *WhereBuilder) WhereOrPrefixBetween(prefix string, column string, min, m
5658
5759// WhereOrPrefixLike builds `prefix.column LIKE 'like'` statement in `OR` conditions.
5860func (b * WhereBuilder ) WhereOrPrefixLike (prefix string , column string , like any ) * WhereBuilder {
59- return b .WhereOrf (`%s.%s LIKE ?` , b .model .QuoteWord (prefix ), b .model .QuoteWord (column ), like )
61+ likeStr := gconv .String (like )
62+ return b .WhereOrf (`%s.%s LIKE ?` , b .model .QuoteWord (prefix ), b .model .QuoteWord (column ), EscapeLikeString (likeStr ))
6063}
6164
6265// WhereOrPrefixIn builds `prefix.column IN (in)` statement in `OR` conditions.
@@ -80,7 +83,8 @@ func (b *WhereBuilder) WhereOrPrefixNotBetween(prefix string, column string, min
8083
8184// WhereOrPrefixNotLike builds `prefix.column NOT LIKE 'like'` statement in `OR` conditions.
8285func (b * WhereBuilder ) WhereOrPrefixNotLike (prefix string , column string , like any ) * WhereBuilder {
83- return b .WhereOrf (`%s.%s NOT LIKE ?` , b .model .QuoteWord (prefix ), b .model .QuoteWord (column ), like )
86+ likeStr := gconv .String (like )
87+ return b .WhereOrf (`%s.%s NOT LIKE ?` , b .model .QuoteWord (prefix ), b .model .QuoteWord (column ), EscapeLikeString (likeStr ))
8488}
8589
8690// WhereOrPrefixNotIn builds `prefix.column NOT IN (in)` statement.
0 commit comments