- Added a new MsSQL adapter
- Some bugfixes were made within annotations. - Added a new Object Instanciator which allows to manipulate and define how an object from an entity must be instanciated with given value.
This commit is contained in:
1 parent
9df7e65dcf
commit
5bd60129ea
22 files changed
+547
-103
No files matched your search
+19
-9
@@ -22,7 +22,7 @@ class Repository
|
||||
$this->entityClass = $entity;
|
||||
$this->alias = $alias;
|
||||
$this->adapter = $adapter;
|
||||
$this->queryBuilder = new QueryBuilder();
|
||||
$this->queryBuilder = new QueryBuilder( $adapter->adapter() );
|
||||
$this->entityResolver = Ulmus::resolveEntity($entity);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ class Repository
|
||||
|
||||
public function loadFromPk($value, $primaryKey = "id") : EntityCollection
|
||||
{
|
||||
# var_dump("<pre>", $primaryKey);die();
|
||||
return $this->where($primaryKey, $value)->loadOne();
|
||||
}
|
||||
|
||||
@@ -70,21 +69,21 @@ class Repository
|
||||
public function select($fields) : self
|
||||
{
|
||||
$this->queryBuilder->select($fields);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function delete() : self
|
||||
{
|
||||
$this->queryBuilder->delete($this->alias);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function from($table) : self
|
||||
public function from(string $table, string $alias, ? string $schema) : self
|
||||
{
|
||||
foreach((array) $table as $alias => $table) {
|
||||
$this->queryBuilder->from($table, is_numeric($alias) ? null : $alias);
|
||||
}
|
||||
|
||||
$this->queryBuilder->from($table, $alias, null, $schema);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -96,6 +95,7 @@ class Repository
|
||||
public function open(string $condition = Query\Where::CONDITION_AND) : self
|
||||
{
|
||||
$this->queryBuilder->open($condition);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -107,12 +107,14 @@ class Repository
|
||||
public function close() : self
|
||||
{
|
||||
$this->queryBuilder->close();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function where($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_AND);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -124,18 +126,21 @@ class Repository
|
||||
public function or($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_OR);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notWhere(array $condition) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_AND, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function orNot($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->notWhere($condition, Query\Where::CONDITION_OR, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -152,18 +157,21 @@ class Repository
|
||||
public function in($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, $operator);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function orIn($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_OR);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notIn($field, $value) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, Query\Where::OPERATOR_NOT_EQUAL);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -175,12 +183,14 @@ class Repository
|
||||
public function like($field, $value) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, Query\Where::OPERATOR_LIKE, Query\Where::CONDITION_AND);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notLike($field, $value) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, Query\Where::OPERATOR_LIKE, Query\Where::CONDITION_AND, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -263,7 +273,7 @@ class Repository
|
||||
}
|
||||
|
||||
if ( ! $this->queryBuilder->has(Query\From::class) ) {
|
||||
$this->from([ $this->alias => $this->entityResolver->tableName() ]);
|
||||
$this->from($this->entityResolver->tableName(), $this->alias, $this->entityResolver->schemaName());
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -276,7 +286,7 @@ class Repository
|
||||
}
|
||||
|
||||
if ( ! $this->queryBuilder->has(Query\From::class) ) {
|
||||
$this->from([ $this->alias => $this->entityResolver->tableName() ]);
|
||||
$this->from($this->entityResolver->tableName(), $this->alias, $this->entityResolver->schemaName());
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
Reference in new issue
Block a user