Add a SQL method for building searchable queries.
Add tests for that method. Convert Shop/Tax and Shop/Transaction to use that for their JSON generating methods.
This commit is contained in:
parent
d11899cf19
commit
f3fd67378f
4 changed files with 61 additions and 13 deletions
|
|
@ -352,12 +352,7 @@ sub www_getTransactionsAsJson {
|
|||
from transaction';
|
||||
my $keywords = $form->get("keywords");
|
||||
if ($keywords ne "") {
|
||||
$sql .= ' where';
|
||||
foreach my $field (qw(amount username orderNumber shippingAddressName shippingAddress1 paymentAddressName paymentAddress1)) {
|
||||
$sql .= ' or' if (scalar @placeholders > 0);
|
||||
$sql .= qq{ $field like ?};
|
||||
push(@placeholders, '%'.$keywords.'%');
|
||||
}
|
||||
($sql, @placeholders) = $db->buildSearchQuery($sql, $keywords, [qw{amount username orderNumber shippingAddressName shippingAddress1 paymentAddressName paymentAddress1}])
|
||||
}
|
||||
push(@placeholders, $startIndex, $numberOfResults);
|
||||
$sql .= ' order by dateOfPurchase desc limit ?,?';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue