From db26e36ac3de454b9e5e9a4c568d7a3cc3e77413 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Thu, 2 Nov 2023 11:18:56 +0100 Subject: [PATCH] feat: accept CSV string as columns for select() --- src/MySQL.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MySQL.php b/src/MySQL.php index 4791094..e62c7af 100644 --- a/src/MySQL.php +++ b/src/MySQL.php @@ -136,9 +136,12 @@ /* ---- */ // Create Prepared Statament for SELECT with optional WHERE filters - public function select(?array $columns = null): array|bool { + public function select(array|string|null $columns = null): array|bool { $this->throw_if_no_table(); + // Create array of columns from CSV + $columns = is_array($columns) ? $columns : explode(",", $columns); + // Filter columns that aren't in the model if defiend if ($columns && $this->model) { $columns = $this->in_model($columns);