Skip to content

Commit

Permalink
Update filters for mariadb
Browse files Browse the repository at this point in the history
  • Loading branch information
kekefreedog committed Dec 8, 2024
1 parent ed456b2 commit e33e352
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
25 changes: 21 additions & 4 deletions src/Driver/Model/Mariadb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

Expand Down Expand Up @@ -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

Expand Down
20 changes: 19 additions & 1 deletion src/Library/Database/Driver/Mariadb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e33e352

Please sign in to comment.