From e33e3527ee9306de0ecfcacb50b13f2686cd0f72 Mon Sep 17 00:00:00 2001 From: kekefreedog <70959083+kekefreedog@users.noreply.github.com> Date: Mon, 9 Dec 2024 00:27:48 +0100 Subject: [PATCH] Update filters for mariadb --- src/Driver/Model/Mariadb.php | 25 +++++++++++++++++++++---- src/Library/Database/Driver/Mariadb.php | 20 +++++++++++++++++++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/Driver/Model/Mariadb.php b/src/Driver/Model/Mariadb.php index 05331c3..78e4482 100644 --- a/src/Driver/Model/Mariadb.php +++ b/src/Driver/Model/Mariadb.php @@ -185,10 +185,10 @@ public function parseFilter(?array $filters, ?array $options = null):self { if(isset($filters) && is_array($filters)){ # Process Operations In Filters - $filters = $this->_processOperationsInFilters($filters); + # $filters = $this->_processOperationsInFilters($filters); # Push filters in filters - $this->conditions[] = $filters; + $this->conditions = $filters; } @@ -584,8 +584,25 @@ public function run():array { }else{ - # Set result - $result = $this->mariadb->find($this->arguments["table"]); + # Check conditions + if($this->conditions !== null){ + + # Set result + $result = $this->mariadb->find( + $this->arguments["table"], + "", + [ + "filters" => $this->conditions + ] + ); + + + }else{ + + # Set result + $result = $this->mariadb->find($this->arguments["table"]); + + } ## Fields filter | end diff --git a/src/Library/Database/Driver/Mariadb.php b/src/Library/Database/Driver/Mariadb.php index 88849c5..188ffab 100644 --- a/src/Library/Database/Driver/Mariadb.php +++ b/src/Library/Database/Driver/Mariadb.php @@ -969,14 +969,32 @@ public function find(string $table, string $database = "", array $options = []): $result = $statment->fetchAll(PDO::FETCH_ASSOC); }else + # Check filters + if(!empty($filters)){ + + # Set instance + $instance = $this->manager->from($table); + + # Iteration filters + foreach($filters as $key => $value){ + + $instance->where($key, $value); + + } + + # Update table + $result = $instance->fetchAll(); + + }else{ # Update table $result = $this->manager ->from($table) - ->where($filters) ->fetchAll() ; + } + } catch (PDOException $e) { # New exception