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 @@ -50,12 +50,16 @@ private function execute($statement)
5050
5151 private function search ($ table , $ filters )
5252 {
53- $ stmt = $ this ->conn ->prepare (
54- "SELECT * FROM $ table WHERE " .
55- implode (" and " , array_map (fn ($ x ) => "$ x=: $ x " , array_keys ($ filters )))
56- );
57- foreach ($ filters as $ key => $ val ) {
58- $ stmt ->bindValue (": $ key " , $ val );
53+ if (count ($ filters ) > 0 ) {
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 );
60+ }
61+ } else {
62+ $ stmt = $ this ->conn ->prepare ("SELECT * FROM $ table " );
5963 }
6064 $ this ->execute ($ stmt );
6165 return $ stmt ->fetchAll ();
You can’t perform that action at this time.
0 commit comments