mirror of
https://codeberg.org/vlw/php-mysql.git
synced 2025-09-14 08:43:40 +02:00
feat: add protected array property for where statement columns (#40)
This PR adds a compliment for the `MySQL->filter_values` property but for filter columns which can be accessed from a protected scope with `MySQL->filter_columns` Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/40
This commit is contained in:
parent
d5f1efb9b9
commit
64c7bae3cf
1 changed files with 4 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
||||||
protected string $table;
|
protected string $table;
|
||||||
protected ?string $limit = null;
|
protected ?string $limit = null;
|
||||||
protected ?string $order_by = null;
|
protected ?string $order_by = null;
|
||||||
|
protected array $filter_columns = [];
|
||||||
protected array $filter_values = [];
|
protected array $filter_values = [];
|
||||||
protected ?string $filter_sql = null;
|
protected ?string $filter_sql = null;
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@
|
||||||
// Unset filters if null was passed
|
// Unset filters if null was passed
|
||||||
if ($conditions === null) {
|
if ($conditions === null) {
|
||||||
$this->filter_sql = null;
|
$this->filter_sql = null;
|
||||||
|
$this->filter_columns = null;
|
||||||
$this->filter_values = null;
|
$this->filter_values = null;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -93,6 +95,8 @@
|
||||||
|
|
||||||
// Create SQL string and append values to array for prepared statement
|
// Create SQL string and append values to array for prepared statement
|
||||||
foreach ($condition as $col => $operation) {
|
foreach ($condition as $col => $operation) {
|
||||||
|
$this->filter_columns[] = $col;
|
||||||
|
|
||||||
// Assume we want an equals comparison if value is not an array
|
// Assume we want an equals comparison if value is not an array
|
||||||
if (!is_array($operation)) {
|
if (!is_array($operation)) {
|
||||||
$operation = [Operators::EQUALS->value => $operation];
|
$operation = [Operators::EQUALS->value => $operation];
|
||||||
|
|
Loading…
Add table
Reference in a new issue