Skip to content

Commit 94e3d87

Browse files
committed
updated Model::map method
`Model::map` - added `$filters` param
1 parent fda66f2 commit 94e3d87

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Model.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,16 @@ private static function _get_model_info() {
147147
* the field to map
148148
*
149149
*/
150-
public static function map($field = 'id') {
150+
public static function map($field = 'id', $filters = []) {
151151
$model = self::_get_model_info();
152152
if (!$model) return false;
153153
if (!self::get_field($field)) return false;
154154

155155
$table = $model['table'];
156156
$active_field = self::get_field('active') ? "active = 1" : "";
157157

158-
$data = self::query("SELECT $field FROM `$table` WHERE $active_field");
158+
$filters_str = self::create_filter($filters, $binds);
159+
$data = self::query("SELECT $field FROM `$table` WHERE $active_field $filters_str", $binds);
159160
if (!$data) return [];
160161

161162
return array_map(function($row) use ($field) {

0 commit comments

Comments
 (0)