protected function fetch($entityName, array $conditions, $result = false)
    {
        $query = $this->storage->read($entityName);

        foreach ($conditions as $field => $values) {
            $query->where($field, $values);
        }

        if (!$result) {
            return $query->execute();
        }

        foreach ($this->relations as $relation) {
            $query->with($relation->name());
        }

        foreach ($this->conditions as $condition) {
            $query->where($condition[0], $condition[1], $condition[2], $condition[3]);
        }

        foreach ($this->orders as $order) {
            $query->order($order[0], $order[1]);
        }

        if ($this->limit !== null || $this->offset !== null) {
            $query->limit($this->limit, $this->offset);
        }

        return $query->execute();
    }
protected function fetch($entityName, array $conditions, $result = false)
    {
        $query = $this->storage->read($entityName);

        foreach ($conditions as $field => $values) {
            $query->where($field, $values);
        }

        if (!$result) {
            return $query->execute();
        }

        foreach ($this->relations as $relation) {
            $query->with($relation->name());
        }

        foreach ($this->conditions as $condition) {
            $query->where($condition[0], $condition[1], $condition[2], $condition[3]);
        }

        foreach ($this->orders as $order) {
            $query->order($order[0], $order[1]);
        }

        if ($this->limit !== null || $this->offset !== null) {
            $query->limit($this->limit, $this->offset);
        }

        return $query->execute();
    }
protected function fetch ( $ entityName , array $ conditions , $ result = false ) { $ query = $ this -> storage -> read ( $ entityName ) ; foreach ( $ conditions as $ field => $ values ) { $ query -> where ( $ field , $ values ) ; } if ( ! $ result ) { return $ query -> execute ( ) ; } foreach ( $ this -> relations as $ relation ) { $ query -> with ( $ relation -> name ( ) ) ; } foreach ( $ this -> conditions as $ condition ) { $ query -> where ( $ condition [ 0 ] , $ condition [ 1 ] , $ condition [ 2 ] , $ condition [ 3 ] ) ; } foreach ( $ this -> orders as $ order ) { $ query -> order ( $ order [ 0 ] , $ order [ 1 ] ) ; } if ( $ this -> limit !== null || $ this -> offset !== null ) { $ query -> limit ( $ this -> limit , $ this -> offset ) ; } return $ query -> execute ( ) ; }
Fetches collection of entities matching set conditions
Optionally sorts it and limits it

@param string $entityName
@param array  $conditions
@param bool   $result

@return array
Fetches collection of entities matching set conditions Optionally sorts it and limits it