Skip to content

Commit 3497170

Browse files
committed
fix: make sure $this->tableName is string
1 parent b8fe16d commit 3497170

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

system/Database/BaseBuilder.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ class BaseBuilder
158158
* Tracked separately because $QBFrom gets escaped
159159
* and prefixed.
160160
*
161+
* When $tableName to the constructor has multiple tables,
162+
* the value is empty string.
163+
*
161164
* @var string
162165
*/
163166
protected $tableName;
@@ -276,7 +279,13 @@ public function __construct($tableName, ConnectionInterface &$db, ?array $option
276279
*/
277280
$this->db = $db;
278281

279-
$this->tableName = $tableName;
282+
// If it contains `,`, it has multiple tables
283+
if (is_string($tableName) && strpos($tableName, ',') === false) {
284+
$this->tableName = $tableName; // @TODO remove alias if exists
285+
} else {
286+
$this->tableName = '';
287+
}
288+
280289
$this->from($tableName);
281290

282291
if (! empty($options)) {

0 commit comments

Comments
 (0)