有没有人知道有一种快速的方法可以不用DQL就能使用Doctrine获取表中的所有记录。
是我漏掉了什么,还是你只需要在类中编写公共函数?
发布于 2011-08-30 19:07:21
如果您有一个实体类(Doctrine Repository manual):
$records = $em->getRepository("Entities\YourTargetEntity")->findAll();
如果没有实体类(PDO manual):
$pdo = $em->getCurrentConnection()->getDbh();
$result = $pdo->query("select * from table"); //plain sql query here, it's just PDO
$records = $pdo->fetchAll();
https://stackoverflow.com/questions/7240341
复制相似问题