*/ private ?array $fields; private ?Select $from; /** * @internal */ public function __construct( private readonly QueryBuilder $sql, private readonly string $table, ) { } /** * @param list $fields */ public function fields(array $fields): self { $this->fields = $fields; return $this; } public function from(Select $from): self { $this->from = $from; return $this; } /** * @param array $params */ public function execute(array $params = []): void { $this->sql->_executeInsertFromSelect($this, $params); } /** * @internal */ public function _getTable(): string { return $this->table; } /** * @internal * @return list */ public function _getFields(): array { if (!isset($this->fields)) { throw new InvalidSqlException('INSERT SELECT: $fields must be set before calling execute()'); } return $this->fields; } public function _getFrom(): Select { if (!isset($this->from)) { throw new InvalidSqlException('INSERT SELECT: $from must be set before calling execute()'); } return $this->from; } }