feat: accept CSV string as columns for select()

This commit is contained in:
Victor Westerlund 2023-11-02 11:18:56 +01:00
parent 5abcb48010
commit db26e36ac3

View file

@ -136,9 +136,12 @@
/* ---- */ /* ---- */
// Create Prepared Statament for SELECT with optional WHERE filters // 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(); $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 // Filter columns that aren't in the model if defiend
if ($columns && $this->model) { if ($columns && $this->model) {
$columns = $this->in_model($columns); $columns = $this->in_model($columns);