- Work done on many-to-many relations - code must still be refactored out of the EntityTrait.

- Fixed Entity::field("propertyname") function to look for name into @Field() annotation and returns it if it exists.
- A lot of bug fixes made into SQL fragments.
This commit is contained in:
Dave Mc Nicoll committed 2020-04-09 09:50:09 -04:00
1 parent 6e84fc7195
commit c64c7778bd
20 files changed
+220 -105

No files matched your search

+26 -13
View File
@@ -2,7 +2,11 @@
namespace Ulmus\Query;
use Ulmus\QueryBuilder;
class Join extends Fragment {
const SQL_TOKEN = "JOIN";
const TYPE_LEFT = "LEFT";
const TYPE_RIGHT = "RIGHT";
@@ -14,24 +18,33 @@ class Join extends Fragment {
public bool $outer = false;
public array $joins = [];
public string $attachment = "ON";
public string $side;
public /*string|QueryBuilder*/ $table;
public string $field;
public /*string|QueryBuilder*/ $value;
public /* QueryBuilder */ $queryBuilder;
public function add(string $side, string $table, string $field, $value)
public function __construct(QueryBuilder $queryBuilder) {
$this->queryBuilder = $queryBuilder;
}
public function set(string $side, /* QueryBuilder|string */ $table, string $field, /* QueryBuilder|string */ $value)
{
$this->joins[] = [
'side' => $side,
'table' => $table,
'field' => $field,
'value' => $value,
];
$this->side = $side;
$this->table = $table;
$this->field = $field;
$this->value = $value;
}
public function render() : string
{
return $this->renderSegments([
#'JOIN',
# table,
# 'ON',
# WHERE ! ,
]);
return $this->renderSegments([ $this->side, static::SQL_TOKEN, $this->table, $this->attachment, $this->field, "=", $this->value ]);
}
}