Skip to content

Commit 5c43d7c

Browse files
author
Nikita Chernyi
committed
Added $fields argument to Entity::loadAll()
1 parent 09b7d3f commit 5c43d7c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Entity.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,17 @@ public function load($value, $field = 'id', array $fields = null): self
174174
/**
175175
* Get all entities from db.
176176
*
177-
* @param array $where Where clause
178-
* @param bool $assoc Return collection of entity objects OR of assoc arrays
177+
* @param array $where Where clause
178+
* @param bool $assoc Return collection of entity objects OR of assoc arrays
179+
* @param array $fields Fields to load, default is all
179180
*
180181
* @return Collection
181182
*/
182-
public function loadAll(array $where = [], bool $assoc = false): Collection
183+
public function loadAll(array $where = [], bool $assoc = false, array $fields = null): Collection
183184
{
184-
$allData = $this->medoo->select($this->getTable(), '*', $where);
185+
$allData = $this->medoo->select($this->getTable(), $fields ? $fields : '*', $where);
185186
$this->sentry->breadcrumbs->record([
186-
'message' => 'Entity '.$this->__getEntityName().'::loadAll('.\print_r($where, true).')',
187+
'message' => 'Entity '.$this->__getEntityName().'::loadAll('.\print_r($where, true).', '.$assoc.', '.\print_r($fields, true).')',
187188
'data' => ['query' => $this->medoo->last()],
188189
'category' => 'Database',
189190
'level' => 'info',

0 commit comments

Comments
 (0)