context = DatabaseConnection::i()->getContext(); $this->photos = $this->context->table("photos"); } function get(int $id): ?Photo { $photo = $this->photos->get($id); if(!$photo) return NULL; return new Photo($photo); } function getByOwnerAndVID(int $owner, int $vId): ?Photo { $photo = $this->photos->where([ "owner" => $owner, "virtual_id" => $vId, ])->fetch(); if(!$photo) return NULL; return new Photo($photo); } function getEveryUserPhoto(User $user): \Traversable { $photos = $this->photos->where([ "owner" => $user->getId() ]); foreach($photos as $photo) { yield new Photo($photo); } } }