Kdyby\Doctrine\EntityRepository::fetchOne PHP Метод

fetchOne() публичный Метод

public fetchOne ( Kdyby\Persistence\Query $queryObject ) : object
$queryObject Kdyby\Persistence\Query
Результат object
    public function fetchOne(Persistence\Query $queryObject)
    {
        try {
            return $queryObject->fetchOne($this);
        } catch (NoResultException $e) {
            return NULL;
        } catch (NonUniqueResultException $e) {
            // this should never happen!
            throw new InvalidStateException("You have to setup your query calling ->setMaxResult(1).", 0, $e);
        } catch (\Exception $e) {
            throw $this->handleQueryException($e, $queryObject);
        }
    }

Usage Example

Пример #1
0
 /**
  * @param QueryObject $listingsQuery
  * @return Listing|null
  * @throws ListingNotFoundException
  */
 public function fetchListing(QueryObject $listingsQuery)
 {
     $listing = $this->listingsRepository->fetchOne($listingsQuery);
     if ($listing === null) {
         throw new ListingNotFoundException();
     }
     return $listing;
 }
All Usage Examples Of Kdyby\Doctrine\EntityRepository::fetchOne