- 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

+34
View File
@@ -0,0 +1,34 @@
<?php
namespace Ulmus\Query;
class OrderBy extends Fragment {
public int $order = 70;
public array $orderBy = [];
public function set(array $order) : self
{
$this->orderBy = $order;
return $this;
}
public function add(string $field, ? string $direction = null) : self
{
$this->orderBy[] = [ $field, $direction ];
return $this;
}
public function render() : string
{
$list = array_map(function($item) {
list($field, $direction) = $item;
return $field . ( $direction ? " $direction" : "" );
}, $this->orderBy);
return $this->renderSegments([
'ORDER BY', implode(", ", $list)
]);
}
}