- Added the HAVING and TRUNCATE keyword
- Fixed GroupBy which was not implemented yet - Added a new SQL raw() function - From statement now accepts subqueries
This commit is contained in:
1 parent
538af38769
commit
139504f8dd
17 files changed
+566
-251
No files matched your search
+18
-6
@@ -3,9 +3,13 @@
|
||||
namespace Ulmus\Query;
|
||||
|
||||
use Ulmus\QueryBuilder;
|
||||
use Ulmus\Repository\ConditionTrait;
|
||||
|
||||
class Join extends Fragment {
|
||||
class Join extends Fragment
|
||||
{
|
||||
use ConditionTrait;
|
||||
|
||||
const SQL_OUTER = "OUTER";
|
||||
const SQL_TOKEN = "JOIN";
|
||||
|
||||
const TYPE_LEFT = "LEFT";
|
||||
@@ -33,8 +37,10 @@ class Join extends Fragment {
|
||||
|
||||
public /* QueryBuilder */ $queryBuilder;
|
||||
|
||||
public function __construct(QueryBuilder $queryBuilder) {
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
public function __construct(QueryBuilder $queryBuilder)
|
||||
{
|
||||
$this->queryBuilder = new QueryBuilder();
|
||||
$this->queryBuilder->parent = $queryBuilder;
|
||||
}
|
||||
|
||||
public function set(string $side, /* QueryBuilder|string */ $table, string $field, /* QueryBuilder|string */ $value)
|
||||
@@ -44,9 +50,15 @@ class Join extends Fragment {
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
public function render() : string
|
||||
{
|
||||
return $this->renderSegments([ strtoupper($this->side), static::SQL_TOKEN, $this->table, $this->alias ?? "", $this->attachment, $this->field, "=", $this->value ]);
|
||||
if ($this->queryBuilder->where ?? false ) {
|
||||
$where = $this->renderSegments([Where::CONDITION_AND, $this->queryBuilder->render(true)]);
|
||||
}
|
||||
|
||||
return $this->renderSegments([
|
||||
strtoupper($this->side), $this->outer ? static::SQL_OUTER : "", static::SQL_TOKEN, $this->table, $this->alias ?? "", $this->attachment, $this->field, "=", $this->value, $where ?? ""
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user