File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,16 @@ private function execute($statement)
5151
5252 private function search ($ table , $ filters )
5353 {
54- $ stmt = $ this ->conn ->prepare (
55- "SELECT * FROM $ table WHERE " .
56- implode (" and " , array_map (fn ($ x ) => "$ x=: $ x " , array_keys ($ filters )))
57- );
58- foreach ($ filters as $ key => $ val ) {
59- $ stmt ->bindValue (": $ key " , $ val );
54+ if (count ($ filters ) > 0 ) {
55+ $ stmt = $ this ->conn ->prepare (
56+ "SELECT * FROM $ table WHERE " .
57+ implode (" and " , array_map (fn ($ x ) => "$ x=: $ x " , array_keys ($ filters )))
58+ );
59+ foreach ($ filters as $ key => $ val ) {
60+ $ stmt ->bindValue (": $ key " , $ val );
61+ }
62+ } else {
63+ $ stmt = $ this ->conn ->prepare ("SELECT * FROM $ table " );
6064 }
6165 $ this ->execute ($ stmt );
6266 return $ stmt ->fetchAll ();
You can’t perform that action at this time.
0 commit comments