fix(payment): constrain creator income counts
This commit is contained in:
1 parent
e20418e909
commit
50ac2119f1
1 file changed
+2
-1
@@ -406,7 +406,8 @@ class Revenue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$where_sql = $where ? 'WHERE ' . implode(' AND ', $where) : '';
|
$where_sql = $where ? 'WHERE ' . implode(' AND ', $where) : '';
|
||||||
$total = (int) ($params ? $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$this->table()} {$where_sql}", $params)) : $wpdb->get_var("SELECT COUNT(*) FROM {$this->table()}"));
|
$count_sql = "SELECT COUNT(*) FROM {$this->table()} {$where_sql}";
|
||||||
|
$total = (int) ($params ? $wpdb->get_var($wpdb->prepare($count_sql, $params)) : $wpdb->get_var($count_sql));
|
||||||
$items_params = array_merge($params, [$limit, $offset]);
|
$items_params = array_merge($params, [$limit, $offset]);
|
||||||
$items = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->table()} {$where_sql} ORDER BY created_at DESC LIMIT %d OFFSET %d", $items_params), ARRAY_A);
|
$items = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$this->table()} {$where_sql} ORDER BY created_at DESC LIMIT %d OFFSET %d", $items_params), ARRAY_A);
|
||||||
return ['items' => $items ?: [], 'total' => $total, 'page' => (int) floor($offset / $limit) + 1, 'max_pages' => (int) ceil(max(1, $total) / $limit)];
|
return ['items' => $items ?: [], 'total' => $total, 'page' => (int) floor($offset / $limit) + 1, 'max_pages' => (int) ceil(max(1, $total) / $limit)];
|
||||||
|
|||||||
Reference in new issue
Block a user