id = $id; $this->date = $date; $this->key = $key; $this->from = $from; $this->where = $where; $this->parameters = $parameters; } public function buildSql(): string { $parameters = []; return strtr( 'SELECT {distinct} {id} AS id, ' . '{date} AS "date", ' . "'{key}' AS type " . 'FROM {from} ' . 'WHERE {where}', [ '{distinct}' => $this->distinct ? 'DISTINCT' : '', '{id}' => $this->getId(), '{date}' => $this->getDate(), '{key}' => $this->getKey(), '{from}' => $this->getFrom(), '{where}' => $this->getWhere(), ] ); } public static function fromArray(array $a) { return new TimelineSingleQuery( $a['id'] ?? null, $a['date'] ?? null, $a['type'] ?? $a['key'] ?? null, $a['FROM'] ?? $a['from'] ?? null, $a['WHERE'] ?? $a['where'] ?? null, $a['parameters'] ?? null ); } public function getDate(): string { return $this->date; } public function getFrom(): string { return $this->from; } public function getId(): string { return $this->id; } public function getKey(): string { return $this->key; } public function getParameters(): array { return $this->parameters; } public function getWhere(): string { return $this->where; } public function isDistinct(): bool { return $this->distinct; } public function setDate(string $date): self { $this->date = $date; return $this; } public function setDistinct(bool $distinct): self { $this->distinct = $distinct; return $this; } public function setFrom(string $from): self { $this->from = $from; return $this; } public function setId(string $id): self { $this->id = $id; return $this; } public function setKey(string $key): self { $this->key = $key; return $this; } public function setParameters(array $parameters): self { $this->parameters = $parameters; return $this; } public function setWhere(string $where): self { $this->where = $where; return $this; } }