- First draft of current WIP

This commit is contained in:
mcndave committed 2019-08-21 16:13:00 -04:00
commit b73d046e0a
47 files changed
+2797

No files matched your search

+43
View File
@@ -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);
}
}