SQL Join table Alias
This commit is contained in:
@@ -16,6 +16,7 @@ use \Driver\SQL\Constraint\PrimaryKey;
|
||||
use \Driver\SQL\Constraint\ForeignKey;
|
||||
use Driver\SQL\Query\CreateTable;
|
||||
use Driver\SQL\Query\Delete;
|
||||
use Driver\SQL\Query\Drop;
|
||||
use Driver\SQL\Query\Insert;
|
||||
use Driver\SQL\Query\Query;
|
||||
use Driver\SQL\Query\Select;
|
||||
@@ -73,6 +74,10 @@ abstract class SQL {
|
||||
return new Update($this, $table);
|
||||
}
|
||||
|
||||
public function drop(string $table) {
|
||||
return new Drop($this, $table);
|
||||
}
|
||||
|
||||
// ####################
|
||||
// ### ABSTRACT METHODS
|
||||
// ####################
|
||||
@@ -107,7 +112,9 @@ abstract class SQL {
|
||||
$joinTable = $this->tableName($join->getTable());
|
||||
$columnA = $this->columnName($join->getColumnA());
|
||||
$columnB = $this->columnName($join->getColumnB());
|
||||
$joinStr .= " $type JOIN $joinTable ON $columnA=$columnB";
|
||||
$tableAlias = ($join->getTableAlias() ? " " . $join->getTableAlias() : "");
|
||||
|
||||
$joinStr .= " $type JOIN $joinTable$tableAlias ON $columnA=$columnB";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,6 +255,12 @@ abstract class SQL {
|
||||
return $this->execute($query, $params);
|
||||
}
|
||||
|
||||
public function executeDrop(Drop $drop) {
|
||||
$query = "DROP TABLE " . $this->tableName($drop->getTable());
|
||||
if ($drop->dump) { var_dump($query); }
|
||||
return $this->execute($query);
|
||||
}
|
||||
|
||||
protected function getWhereClause($conditions, &$params) {
|
||||
if (!$conditions) {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user