web-base/Core/Driver/SQL/Query/Query.class.php

33 lines
705 B
PHP
Raw Permalink Normal View History

2020-04-02 00:02:51 +02:00
<?php
2022-11-18 18:06:46 +01:00
namespace Core\Driver\SQL\Query;
2020-04-02 00:02:51 +02:00
2022-11-18 18:06:46 +01:00
use Core\Driver\SQL\Expression\Expression;
use Core\Driver\SQL\SQL;
2020-04-03 17:39:58 +02:00
2021-04-08 19:08:05 +02:00
abstract class Query extends Expression {
2020-04-02 00:02:51 +02:00
2020-04-03 17:39:58 +02:00
protected SQL $sql;
2020-04-04 01:15:59 +02:00
public bool $dump;
2020-04-02 00:02:51 +02:00
2021-04-02 21:58:06 +02:00
public function __construct(SQL $sql) {
2020-04-02 00:02:51 +02:00
$this->sql = $sql;
2020-04-04 01:15:59 +02:00
$this->dump = false;
}
2021-04-02 21:58:06 +02:00
public function dump(): Query {
2020-04-04 01:15:59 +02:00
$this->dump = true;
return $this;
2020-04-02 00:02:51 +02:00
}
2021-04-02 22:41:24 +02:00
// can actually return bool|array (depending on success and query type)
2021-04-08 18:29:47 +02:00
public function execute() {
return $this->sql->executeQuery($this);
}
2021-04-09 16:05:36 +02:00
public abstract function build(array &$params): ?string;
public function getExpression(SQL $sql, array &$params): string {
return "(" . $this->build($params) . ")";
}
2020-04-03 17:39:58 +02:00
}