|
|
@@ -46,19 +46,29 @@ abstract class AbstractRepositoryQuery |
|
|
|
return $this; |
|
|
|
} |
|
|
|
|
|
|
|
public function count(): string |
|
|
|
{ |
|
|
|
return $this->query->getQuery() |
|
|
|
->getSingleScalarResult(); |
|
|
|
} |
|
|
|
|
|
|
|
public function findOne() |
|
|
|
{ |
|
|
|
return $this->query->getQuery() |
|
|
|
->setMaxResults(1) |
|
|
|
->getOneOrNullResult() |
|
|
|
; |
|
|
|
->getOneOrNullResult(); |
|
|
|
} |
|
|
|
|
|
|
|
public function find() :array |
|
|
|
public function find(): array |
|
|
|
{ |
|
|
|
return $this->query->getQuery()->getResult(); |
|
|
|
} |
|
|
|
|
|
|
|
public function limit(int $maxResults): self |
|
|
|
{ |
|
|
|
return $this->query->setMaxResults($maxResults); |
|
|
|
} |
|
|
|
|
|
|
|
public function paginate(int $page = 1, int $limit = 20) |
|
|
|
{ |
|
|
|
return $this->paginator->paginate($this->query->getQuery(), $page, $limit); |
|
|
@@ -76,7 +86,7 @@ abstract class AbstractRepositoryQuery |
|
|
|
|
|
|
|
foreach ($words as $k => $v) { |
|
|
|
if (isset($v[0]) && '.' === $v[0]) { |
|
|
|
$words[$k] = $this->id.$v; |
|
|
|
$words[$k] = $this->id . $v; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -90,11 +100,12 @@ abstract class AbstractRepositoryQuery |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
|
public function orderBy($field, $sort){ |
|
|
|
if(substr($field,0,1)=== '.'){ |
|
|
|
return $this->addOrderBy($field, $sort) ; |
|
|
|
}else{ |
|
|
|
return $this->addOrderBy('.'.$field, $sort) ; |
|
|
|
public function orderBy(string $field, string $sort = 'ASC'): self |
|
|
|
{ |
|
|
|
if (substr($field, 0, 1) === '.') { |
|
|
|
return $this->addOrderBy($field, $sort); |
|
|
|
} else { |
|
|
|
return $this->addOrderBy('.' . $field, $sort); |
|
|
|
} |
|
|
|
} |
|
|
|
|