php - Doctrine returns different responses array/object -


i have 2 doctrine queries so:

fetchbookrepository:

public function fetchbook($id) {     try {         $book = $this->em->getrepository('booksapibookbundle:booksentity')             ->find($id);         var_dump($book);die();      } catch (\exception $ex) {         $this->em->close();         throw new queryexception('003', 502);     }      return $book; } 

fetchallbooksrepository:

public function allbooks() {     try {         $book = $this->em->getrepository('booksapibookbundle:booksentity')             ->findall();          var_dump($book);die();      } catch (\exception $ex) {         $this->em->close();         throw new queryexception('003', 502);     }      return $book; } 

they both work expected, when closely investigate data returned noticed fetchbookrepository returns object , fetchallbooksrepository returns array of objects.

fetchbookrepository fetchallbooksrepository

why happening return depend on , there way standardise return...?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -