- $id = 0;
- while ($this->store->retrieveOneById($id,$this->user->getId()) == null) {
- $count = $this->store->getEntriesByViewCount($view, $this->user->getId());
- $id = rand(1,$count);
- }
+ $count = $this->store->getEntriesByViewCount($view, $this->user->getId());
+ $id_query = $this->store->getRandomId(rand(1,$count)-1, $this->user->getId());
+ $id = $id_query[0];