Compare commits

..

No commits in common. "c64eb96049907da60dc9f237d26aef0e531b0015" and "64c7bae3cf6124dcb64c9e8ef93425be3602e82a" have entirely different histories.

2 changed files with 8 additions and 22 deletions

View file

@ -8,10 +8,8 @@
use mysqli_stmt;
use mysqli_result;
use vlw\MySQL\Order;
use vlw\MySQL\Operators;
require_once "Order.php";
require_once "Operators.php";
// Interface for MySQL_Driver with abstractions for data manipulation
@ -52,11 +50,7 @@
// Convert all boolean type values to tinyints in array
private static function filter_booleans(array $values): array {
return array_map(fn(mixed $v): mixed => gettype($v) === "boolean" ? self::filter_boolean($v) : $v, $values);
}
private static function array_wrap_accents(array $input): array {
return array_map(fn(mixed $v): string => "`{$v}`", $input);
return array_map(fn($v): mixed => gettype($v) === "boolean" ? self::filter_boolean($v) : $v, $values);
}
/*
@ -180,12 +174,12 @@
return $this;
}
// Assign Order Enum entries from array of arrays<Order|string>
$orders = array_map(fn(Order|string $order): Order => $order instanceof Order ? $order : Order::tryFrom($order), array_values($order_by));
// Create CSV string with Prepared Statement abbreviations from length of fields array.
$sql = array_map(fn(string $column, Order|string $order): string => "`{$column}` " . $order->value, array_keys($order_by), $orders);
// Create CSV from columns
$sql = implode(",", array_keys($order_by));
// Create pipe DSV from values
$sql .= " " . implode("|", array_values($order_by));
$this->order_by = implode(",", $sql);
$this->order_by = $sql;
return $this;
}
@ -202,7 +196,7 @@
$this->columns = is_array($columns) || is_null($columns) ? $columns : explode(",", $columns);
// Create CSV from columns or default to SQL NULL as a string
$columns_sql = $this->columns ? implode(",", self::array_wrap_accents($this->columns)) : "NULL";
$columns_sql = $this->columns ? implode(",", $this->columns) : "NULL";
// Create LIMIT statement if argument is defined
$limit_sql = !is_null($this->limit) ? " LIMIT {$this->limit}" : "";
@ -224,7 +218,7 @@
$this->throw_if_no_table();
// Create CSV string with Prepared Statement abbreviations from length of fields array.
$changes = array_map(fn($column) => "`{$column}` = ?", array_keys($entity));
$changes = array_map(fn($column) => "{$column} = ?", array_keys($entity));
$changes = implode(",", $changes);
// Get array of SQL WHERE string and filter values

View file

@ -1,8 +0,0 @@
<?php
namespace vlw\MySQL;
enum Order: string {
case ASC = "ASC";
case DESC = "DESC";
}