mirror of
https://codeberg.org/vlw/php-mysql.git
synced 2025-09-13 16:23:42 +02:00
feat(cleanup): remove flatten()
class method (#39)
This commit is contained in:
parent
a26db46aae
commit
a19ed09a34
1 changed files with 2 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue