expr = $database; // case 1 $this->alias = $table; // case 2 } else { $this->database = $database; // case 3 $this->table = $table; // case 3 $this->column = $column; // case 3 $this->alias = $alias; // case 4 } } public function build(): string { if ($this->expr !== '' && $this->expr !== null) { $ret = $this->expr; } else { $fields = []; if (isset($this->database) && ($this->database !== '')) { $fields[] = $this->database; } if (isset($this->table) && ($this->table !== '')) { $fields[] = $this->table; } if (isset($this->column) && ($this->column !== '')) { $fields[] = $this->column; } $ret = implode('.', Context::escapeAll($fields)); } if (! empty($this->alias)) { $ret .= ' AS ' . Context::escape($this->alias); } return $ret; } public function __toString(): string { return $this->build(); } }