Like @Lighthart, as shown, yes, it is possible, although it adds significant fat to the controller and is NOT DRY.
You really need to define your own query in the object repository, this is a simple and best practice.
use Doctrine\ORM\EntityRepository; class UserRepository extends EntityRepository { public function findAll() { return $this->findBy(array(), array('username' => 'ASC')); } }
Then you must tell your entity to search for queries in the repository:
class User { ... }
Finally, in your controller:
$this->getDoctrine()->getRepository('AcmeBundle:User')->findAll();
Pier-Luc Gendreau Jun 15 '13 at 4:09 2013-06-15 04:09
source share