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.
why happening return depend on , there way standardise return...?
Comments
Post a Comment