- First draft of current WIP
This commit is contained in:
commit
b73d046e0a
47 files changed
+2797
No files matched your search
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Query;
|
||||
|
||||
class From extends Fragment {
|
||||
|
||||
public int $order = -80;
|
||||
|
||||
protected $tables = [];
|
||||
|
||||
public function set(array $tables) : self
|
||||
{
|
||||
$this->tables = $tables;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function add($table) : self
|
||||
{
|
||||
foreach((array) $table as $alias => $name) {
|
||||
$this->tables[$alias] = $name;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() : string
|
||||
{
|
||||
return $this->renderSegments([
|
||||
'FROM', $this->renderTables(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function renderTables() : string
|
||||
{
|
||||
$list = [];
|
||||
|
||||
foreach((array) $this->tables as $alias => $table) {
|
||||
$list[] = ! is_numeric($alias) ? "`$table` $alias" : "`$table`";
|
||||
}
|
||||
|
||||
return implode(", ", $list);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user