Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine 2 - Get all Records

Tags:

Does anyone know is there is a quick way to get all the records in a table using Doctrine with out using the DQL.

Did I miss something or did you need to just write the public function in the class?

like image 234
space_balls Avatar asked Aug 30 '11 08:08

space_balls


1 Answers

If you have an entity class (Doctrine Repository manual):

$records = $em->getRepository("Entities\YourTargetEntity")->findAll(); 

If you don't have entity class (PDO manual):

$pdo = $em->getCurrentConnection()->getDbh(); $result = $pdo->query("select * from table"); //plain sql query here, it's just PDO $records = $pdo->fetchAll(); 
like image 55
J0HN Avatar answered Oct 21 '22 07:10

J0HN