diff --git a/app/repositories/CommentsRepository.asp b/app/repositories/CommentsRepository.asp index a7dfc95..6c3a8a6 100644 --- a/app/repositories/CommentsRepository.asp +++ b/app/repositories/CommentsRepository.asp @@ -30,6 +30,7 @@ Class CommentsRepository_Class Public Function Find(where_kvarray, order_string_or_array) Dim sql : sql = "Select [AuthorEmail], [AuthorName], [Body], [CommentID], [CreatedDate], [IsApproved], [PostID] FROM [Comments]" Dim where_keys, where_values, i + where_values = Empty If Not IsEmpty(where_kvarray) Then KVUnzip where_kvarray, where_keys, where_values If Not IsEmpty(where_keys) Then @@ -51,14 +52,15 @@ Class CommentsRepository_Class Destroy rs End Function - Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) - Dim sql : sql = "Select [AuthorEmail], [AuthorName], [Body], [CommentID], [CreatedDate], [IsApproved], [PostID] FROM [Comments]" - Dim where_keys, where_values, i - If Not IsEmpty(where_kvarray) Then - KVUnzip where_kvarray, where_keys, where_values - If Not IsEmpty(where_keys) Then - sql = sql & " WHERE " - For i = 0 To UBound(where_keys) + Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) + Dim sql : sql = "Select [AuthorEmail], [AuthorName], [Body], [CommentID], [CreatedDate], [IsApproved], [PostID] FROM [Comments]" + Dim where_keys, where_values, i + where_values = Empty + If Not IsEmpty(where_kvarray) Then + KVUnzip where_kvarray, where_keys, where_values + If Not IsEmpty(where_keys) Then + sql = sql & " WHERE " + For i = 0 To UBound(where_keys) If i > 0 Then sql = sql & " AND " sql = sql & " " & QI(where_keys(i)) & " = ?" Next @@ -76,13 +78,14 @@ Class CommentsRepository_Class Destroy rs End Function - Public Function SearchTablePaged(columns_array, search_value, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) - Dim sql : sql = "Select [AuthorEmail], [AuthorName], [Body], [CommentID], [CreatedDate], [IsApproved], [PostID] FROM [Comments]" - Dim i, params() - If IsArray(columns_array) And UBound(columns_array) >= 0 Then - sql = sql & " WHERE " - ReDim params(UBound(columns_array)) - For i = 0 To UBound(columns_array) + Public Function SearchTablePaged(columns_array, search_value, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) + Dim sql : sql = "Select [AuthorEmail], [AuthorName], [Body], [CommentID], [CreatedDate], [IsApproved], [PostID] FROM [Comments]" + Dim i, params() + params = Empty + If IsArray(columns_array) And UBound(columns_array) >= 0 Then + sql = sql & " WHERE " + ReDim params(UBound(columns_array)) + For i = 0 To UBound(columns_array) If i > 0 Then sql = sql & " OR " sql = sql & " " & QI(columns_array(i)) & " LIKE ?" params(i) = "%" & search_value & "%"