File tree Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -67,27 +67,22 @@ public static function instance($arg1, $arg2 = null) {
67
67
$ table = $ model ['table ' ];
68
68
69
69
if (isset ($ arg2 )) {
70
- $ fields = "` $ arg1` = :value " ;
71
- $ bind = [':value ' => $ arg2 ];
70
+ $ filter_str = "` $ arg1` = :value " ;
71
+ $ binds = [':value ' => $ arg2 ];
72
72
} else {
73
73
if (is_array ($ arg1 )) {
74
- $ filters = [];
75
- $ bind = [];
76
- foreach ($ arg1 as $ key => $ value ) {
77
- $ filters [] = "` $ key` = : $ key " ;
78
- $ bind [$ key ] = $ value ;
79
- }
80
-
81
- $ fields = implode (' AND ' , $ filters );
74
+ $ filter_str = self ::create_filter ($ arg1 , $ binds , null );
82
75
} else {
83
- $ fields = "`id` = :value " ;
84
- $ bind = [':value ' => $ arg1 ];
76
+ $ filter_str = "`id` = :value " ;
77
+ $ binds = [':value ' => $ arg1 ];
85
78
}
86
79
}
87
80
88
- $ active_field = self ::get_field ('active ' ) ? "AND active = 1 " : "" ;
81
+ if (self ::get_field ('active ' )) {
82
+ $ filter_str = 'active = 1 AND ' .$ filter_str ;
83
+ }
89
84
90
- return self ::query_row ("SELECT * FROM ` $ table` WHERE $ fields $ active_field " , $ bind );
85
+ return self ::query_row ("SELECT * FROM ` $ table` WHERE $ filter_str " , $ binds );
91
86
}
92
87
93
88
public static function connect ($ host , $ database , $ username , $ password ) {
You can’t perform that action at this time.
0 commit comments