- 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:
1 parent
6e84fc7195
commit
c64c7778bd
20 files changed
+220
-105
No files matched your search
+27
-13
@@ -53,15 +53,11 @@ class Repository
|
||||
|
||||
public function count() : int
|
||||
{
|
||||
$this->select("count(*) as totalItem")->selectSqlQuery();
|
||||
$this->select("COUNT(*)")->selectSqlQuery();
|
||||
|
||||
$this->finalizeQuery();
|
||||
|
||||
foreach(Ulmus::iterateQueryBuilder($this->queryBuilder, $this->adapter) as $entityData) {
|
||||
return $entityData['totalItem'];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Ulmus::runSelectQuery($this->queryBuilder, $this->adapter)->fetchColumn(0);
|
||||
}
|
||||
|
||||
public function deleteOne()
|
||||
@@ -157,7 +153,7 @@ class Repository
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function update(array $fieldlist, string $table, string $alias, ? string $schema) : self
|
||||
public function update(string $table, string $alias, ? string $schema) : self
|
||||
{
|
||||
$this->queryBuilder->update($table, $alias, $schema);
|
||||
|
||||
@@ -239,21 +235,39 @@ class Repository
|
||||
|
||||
public function orNot($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->notWhere($condition, Query\Where::CONDITION_OR, true);
|
||||
$this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_OR, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function having() : self
|
||||
public function having($field, $value, string $operator = Query\Having::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->having($field, $value, $operator, Query\Having::CONDITION_AND);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notHaving() : self
|
||||
public function orHaving($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->having($field, $value, $operator, Query\Having::CONDITION_OR);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notHaving($field, $value, string $operator = Query\Where::OPERATOR_NOT_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->having($field, $value, $operator, Query\Having::CONDITION_AND, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function orNotHaving($field, $value, string $operator = Query\Where::OPERATOR_NOT_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->having($field, $value, $operator, Query\Having::CONDITION_OR, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function in($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, $operator);
|
||||
@@ -362,10 +376,10 @@ class Repository
|
||||
return $this->where($primaryKeyField[$pkField]->name ?? $pkField, $value);
|
||||
}
|
||||
|
||||
protected function collectionFromQuery() : EntityCollection
|
||||
public function collectionFromQuery(? string $entityClass = null) : EntityCollection
|
||||
{
|
||||
|
||||
$class = $this->entityClass;
|
||||
$class = $entityClass ?: $this->entityClass;
|
||||
|
||||
$entityCollection = new EntityCollection();
|
||||
|
||||
@@ -401,7 +415,7 @@ class Repository
|
||||
protected function updateSqlQuery(array $dataset) : self
|
||||
{
|
||||
if ( null === $this->queryBuilder->getFragment(Query\Update::class) ) {
|
||||
$this->update($dataset, $this->entityResolver->tableName(), $this->alias, $this->entityResolver->schemaName());
|
||||
$this->update($this->entityResolver->tableName(), $this->alias, $this->entityResolver->schemaName());
|
||||
}
|
||||
|
||||
$this->set($dataset);
|
||||
|
||||
Reference in new issue
Block a user