From a19ed09a34c661544ff66db0c883708bb13e245d Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Mon, 29 Apr 2024 08:14:45 +0000 Subject: [PATCH] feat(cleanup): remove `flatten()` class method (#39) --- src/MySQL.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/MySQL.php b/src/MySQL.php index a34bcdf..7147636 100644 --- a/src/MySQL.php +++ b/src/MySQL.php @@ -17,7 +17,6 @@ private string $table; private ?array $model = null; - private bool $flatten = false; private ?string $order_by = null; private ?string $filter_sql = null; private array $filter_values = []; @@ -199,12 +198,6 @@ return $this; } - // Flatten returned array to first entity if set - public function flatten(bool $flag = true): self { - $this->flatten = $flag; - return $this; - } - // Return SQL SORT BY string from assoc array of columns and direction public function order(?array $order_by = null): self { // Unset row order by if null was passed @@ -253,11 +246,8 @@ // Interpolate components into an SQL SELECT statmenet and execute $sql = "SELECT {$columns_sql} FROM `{$this->table}`{$filter_sql}{$order_by_sql}{$limit_sql}"; - - // Return array of matched rows - $exec = $this->execute_query($sql, self::to_list_array($this->filter_values)); - // Return array if exec was successful. Return as flattened array if flag is set - return empty($exec) || !$this->flatten ? $exec : $exec[0]; + // Return mysqli_response of matched rows + return $this->execute_query($sql, self::to_list_array($this->filter_values)); } // Create Prepared Statement for UPDATE using PRIMARY KEY as anchor