Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine 2: What does getResult return when there are no rows? null?

I wonder what is returned by functions like get*Result(). It seems like null? Where in the docs can I find such info?

like image 532
Jiew Meng Avatar asked Jan 22 '11 14:01

Jiew Meng


1 Answers

get*Result() methods return an empty array()
getSingle*Result() methods throw a \Doctrine\ORM\NoResultException

Here are direct links to the doctrine API docs

  • getResult() doctrine API docs
  • getSingleResult() doctrine API docs
  • getSingleScalarResult() doctrine API docs
  • getOneOrNullResult() doctrine API docs

Also important exceptions:

  • NoResultException doctrine API docs
  • NonUniqueResultException doctrine API docs

    (must handle for getSingle*() and getOneOrNullResult() methods)

  • UnexpectedResultException doctrine API docs (this is parent exception of the two above)

direct links are for 2.6, but you can find there more recent versions at the at http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html

like image 54
Arnaud Le Blanc Avatar answered Sep 28 '22 06:09

Arnaud Le Blanc