Some fixes / improvements
This commit is contained in:
@@ -16,10 +16,10 @@ use Driver\SQL\Constraint\ForeignKey;
|
||||
|
||||
class CreateTable extends Query {
|
||||
|
||||
private $tableName;
|
||||
private $columns;
|
||||
private $constraints;
|
||||
private $ifNotExists;
|
||||
private string $tableName;
|
||||
private array $columns;
|
||||
private array $constraints;
|
||||
private bool $ifNotExists;
|
||||
|
||||
public function __construct($sql, $name) {
|
||||
parent::__construct($sql);
|
||||
@@ -92,6 +92,4 @@ class CreateTable extends Query {
|
||||
public function getTableName() { return $this->tableName; }
|
||||
public function getColumns() { return $this->columns; }
|
||||
public function getConstraints() { return $this->constraints; }
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Driver\SQL\Query;
|
||||
|
||||
class Delete extends Query {
|
||||
|
||||
private $table;
|
||||
private $conditions;
|
||||
private string $table;
|
||||
private array $conditions;
|
||||
|
||||
public function __construct($sql, $table) {
|
||||
parent::__construct($sql);
|
||||
@@ -24,6 +24,4 @@ class Delete extends Query {
|
||||
|
||||
public function getTable() { return $this->table; }
|
||||
public function getConditions() { return $this->conditions; }
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace Driver\SQL\Query;
|
||||
|
||||
use Driver\SQL\Strategy\Strategy;
|
||||
|
||||
class Insert extends Query {
|
||||
|
||||
private $tableName;
|
||||
private $columns;
|
||||
private $rows;
|
||||
private $onDuplicateKey;
|
||||
private $returning;
|
||||
private string $tableName;
|
||||
private array $columns;
|
||||
private array $rows;
|
||||
private ?Strategy $onDuplicateKey;
|
||||
private ?string $returning;
|
||||
|
||||
public function __construct($sql, $name, $columns=array()) {
|
||||
parent::__construct($sql);
|
||||
@@ -43,6 +45,4 @@ class Insert extends Query {
|
||||
public function getRows() { return $this->rows; }
|
||||
public function onDuplicateKey() { return $this->onDuplicateKey; }
|
||||
public function getReturning() { return $this->returning; }
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace Driver\SQL\Query;
|
||||
|
||||
use Driver\SQL\SQL;
|
||||
|
||||
abstract class Query {
|
||||
|
||||
protected $sql;
|
||||
protected SQL $sql;
|
||||
|
||||
public function __construct($sql) {
|
||||
$this->sql = $sql;
|
||||
@@ -12,6 +14,4 @@ abstract class Query {
|
||||
|
||||
public abstract function execute();
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
@@ -2,16 +2,18 @@
|
||||
|
||||
namespace Driver\SQL\Query;
|
||||
|
||||
use Driver\SQL\Join;
|
||||
|
||||
class Select extends Query {
|
||||
|
||||
private $columns;
|
||||
private $tables;
|
||||
private $conditions;
|
||||
private $joins;
|
||||
private $orderColumns;
|
||||
private $sortAscending;
|
||||
private $limit;
|
||||
private $offset;
|
||||
private array $columns;
|
||||
private array $tables;
|
||||
private array $conditions;
|
||||
private array $joins;
|
||||
private array $orderColumns;
|
||||
private bool $sortAscending;
|
||||
private int $limit;
|
||||
private int $offset;
|
||||
|
||||
public function __construct($sql, ...$columns) {
|
||||
parent::__construct($sql);
|
||||
@@ -36,12 +38,12 @@ class Select extends Query {
|
||||
}
|
||||
|
||||
public function innerJoin($table, $columnA, $columnB) {
|
||||
$this->joins[] = new \Driver\SQL\Join("INNER", $table, $columnA, $columnB);
|
||||
$this->joins[] = new Join("INNER", $table, $columnA, $columnB);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function leftJoin($table, $columnA, $columnB) {
|
||||
$this->joins[] = new \Driver\SQL\Join("LEFT", $table, $columnA, $columnB);
|
||||
$this->joins[] = new Join("LEFT", $table, $columnA, $columnB);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -51,12 +53,12 @@ class Select extends Query {
|
||||
}
|
||||
|
||||
public function ascending() {
|
||||
$this->ascending = true;
|
||||
$this->sortAscending = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function descending() {
|
||||
$this->ascending = false;
|
||||
$this->sortAscending = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -78,11 +80,9 @@ class Select extends Query {
|
||||
public function getTables() { return $this->tables; }
|
||||
public function getConditions() { return $this->conditions; }
|
||||
public function getJoins() { return $this->joins; }
|
||||
public function isOrderedAscending() { return $this->ascending; }
|
||||
public function isOrderedAscending() { return $this->sortAscending; }
|
||||
public function getOrderBy() { return $this->orderColumns; }
|
||||
public function getLimit() { return $this->limit; }
|
||||
public function getOffset() { return $this->offset; }
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Driver\SQL\Query;
|
||||
|
||||
class Truncate extends Query {
|
||||
|
||||
private $tableName;
|
||||
private string $tableName;
|
||||
|
||||
public function __construct($sql, $name) {
|
||||
parent::__construct($sql);
|
||||
@@ -15,7 +15,5 @@ class Truncate extends Query {
|
||||
return $this->sql->executeTruncate($this);
|
||||
}
|
||||
|
||||
public function getTableName() { return $this->tableName; }
|
||||
};
|
||||
|
||||
?>
|
||||
public function getTable() { return $this->tableName; }
|
||||
}
|
||||
@@ -4,9 +4,9 @@ namespace Driver\SQL\Query;
|
||||
|
||||
class Update extends Query {
|
||||
|
||||
private $values;
|
||||
private $table;
|
||||
private $conditions;
|
||||
private array $values;
|
||||
private string $table;
|
||||
private array $conditions;
|
||||
|
||||
public function __construct($sql, $table) {
|
||||
parent::__construct($sql);
|
||||
@@ -32,6 +32,4 @@ class Update extends Query {
|
||||
public function getTable() { return $this->table; }
|
||||
public function getConditions() { return $this->conditions; }
|
||||
public function getValues() { return $this->values; }
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
Reference in New Issue
Block a user