Skip to content

Commit cbdb1cb

Browse files
allow for more values
Signed-off-by: Diego Andrés <diegoandres_cortes@outlook.com>
1 parent 2072998 commit cbdb1cb

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

Sources/PostPrefix/Helper.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,28 @@ public static function Count($table, $columns, $additional_query = '')
5555
return $rows;
5656
}
5757

58-
public static function Get($start, $items_per_page, $sort, $table, $columns, $additional_query = '', $single = false, $additional_columns = '', $attachments = [])
58+
public static function Get($start, $items_per_page, $sort, $table, $columns, $additional_query = '', $single = false, $additional_columns = '', $more_values = [], $attachments = [])
5959
{
6060
global $smcFunc;
6161

6262
$columns = implode(', ', $columns);
63-
$result = $smcFunc['db_query']('', '
64-
SELECT ' . $columns . '
65-
FROM {db_prefix}{raw:table} ' .
66-
$additional_columns. '
67-
{raw:where}'. (empty($single) ? '
68-
ORDER by {raw:sort}
69-
LIMIT {int:start}, {int:maxindex}' : ''),
63+
$data = array_merge(
7064
[
7165
'table' => $table,
7266
'start' => $start,
7367
'maxindex' => $items_per_page,
7468
'sort' => $sort,
75-
'where' => $additional_query,
76-
]
69+
],
70+
$more_values
71+
);
72+
$result = $smcFunc['db_query']('', '
73+
SELECT ' . $columns . '
74+
FROM {db_prefix}{raw:table} ' .
75+
$additional_columns. '
76+
'. $additional_query . (empty($single) ? '
77+
ORDER BY {raw:sort}
78+
LIMIT {int:start}, {int:maxindex}' : ''),
79+
$data
7780
);
7881

7982
// Single?
@@ -91,23 +94,26 @@ public static function Get($start, $items_per_page, $sort, $table, $columns, $ad
9194
return $items;
9295
}
9396

94-
public static function Nested($sort, $table, $column_main, $column_sec, $query_member, $additional_query = '', $additional_columns = '', $attachments = [], $attach_main = false)
97+
public static function Nested($sort, $table, $column_main, $column_sec, $query_member, $additional_query = '', $additional_columns = '', $more_values = [], $attachments = [], $attach_main = false)
9598
{
9699
global $smcFunc;
97100

98101
$columns = array_merge(array_merge($column_main, $column_sec), $attachments);
99102
$columns = implode(', ', $columns);
103+
$data = array_merge(
104+
[
105+
'table' => $table,
106+
'sort' => $sort,
107+
],
108+
$more_values
109+
);
100110
$result = $smcFunc['db_query']('', '
101111
SELECT ' . $columns . '
102112
FROM {db_prefix}{raw:table} ' .
103113
$additional_columns. '
104-
{raw:where}
114+
'. $additional_query . '
105115
ORDER by {raw:sort}',
106-
[
107-
'table' => $table,
108-
'sort' => $sort,
109-
'where' => $additional_query,
110-
]
116+
$data
111117
);
112118

113119
$items = [];

0 commit comments

Comments
 (0)