. */ namespace SP\Infrastructure\Common\Repositories; use Aura\SqlQuery\Common\Quoter; use Aura\SqlQuery\QueryInterface; /** * Class Query */ final class Query implements QueryInterface { private Quoter $quoter; private function __construct(private readonly string $query, private array $values) { $this->quoter = new Quoter(); } /** * Build an instance of this class for the given database * * @param string $query * @param array $values * * @return Query */ public static function buildForMySQL(string $query, array $values): Query { return new Query($query, $values); } /** * * Builds this query object into a string. * * @return string * */ public function __toString() { return $this->query; } /** * * Returns the prefix to use when quoting identifier names. * * @return string * */ public function getQuoteNamePrefix(): string { return $this->quoter->getQuoteNamePrefix(); } /** * * Returns the suffix to use when quoting identifier names. * * @return string * */ public function getQuoteNameSuffix(): string { return $this->quoter->getQuoteNameSuffix(); } /** * * Adds values to bind into the query; merges with existing values. * * @param array $bind_values Values to bind to the query. * * @return $this * */ public function bindValues(array $bind_values): self { // array_merge() renumbers integer keys, which is bad for // question-mark placeholders foreach ($bind_values as $key => $val) { $this->bindValue($key, $val); } return $this; } /** * * Binds a single value to the query. * * @param string $name The placeholder name or number. * @param mixed $value The value to bind to the placeholder. * * @return $this * */ public function bindValue($name, $value): self { $this->values[$name] = $value; return $this; } /** * @return array */ public function getBindValues(): array { return $this->values; } public function getStatement(): string { return $this->query; } public function resetFlags() { // TODO: Implement resetFlags() method. } }