From 1962e8c82c46b5c4d4ea3c0235cbae590efe59a6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 28 Jun 2024 08:56:39 +0900 Subject: [PATCH] fix: select() may cause TypeError TypeError: trim(): Argument #1 ($string) must be of type string, CodeIgniter\Database\RawSql given --- system/Database/BaseBuilder.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 4e6e422b2a6f..00d75b0b7873 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -390,7 +390,7 @@ public function ignore(bool $ignore = true) /** * Generates the SELECT portion of the query * - * @param array|RawSql|string $select + * @param list|RawSql|string $select * * @return $this */ @@ -402,16 +402,21 @@ public function select($select = '*', ?bool $escape = null) } if ($select instanceof RawSql) { - $this->QBSelect[] = $select; - - return $this; + $select = [$select]; } if (is_string($select)) { - $select = $escape === false ? [$select] : explode(',', $select); + $select = ($escape === false) ? [$select] : explode(',', $select); } foreach ($select as $val) { + if ($val instanceof RawSql) { + $this->QBSelect[] = $val; + $this->QBNoEscape[] = false; + + continue; + } + $val = trim($val); if ($val !== '') {