schema = $table; } public function set(string $col, mixed $val): self { $info = $this->schema->cols[$col]; $type = $info->type; $castedValue = $type->dbCast($val); $this->values[$col] = $castedValue; return $this; } public function toSql(): string { if (empty($this->values)) throw new InvalidArgumentException("No values have been set for the Update."); $table = $this->schema->name; $setParts = []; foreach ($this->values as $col => $value) $setParts[] = "$col = $value"; $setClause = implode(", ", $setParts); // FINAL SQL STATEMENT $update = "UPDATE $table SET $setClause"; if($this->isConditioned()) { $whereClause = $this->combineConditions(); $update .= " WHERE $whereClause"; } return $update; } public function update(): bool { global $wpdb; $query = $this->toSql(); $result = $wpdb->query($query); return boolval($result); } }