【发布时间】:2011-08-30 08:07:36
【问题描述】:
有没有人知道有没有使用 Doctrine 而不使用 DQL 的快速方法来获取表中的所有记录。
是我遗漏了什么,还是你只需要在类中编写公共函数?
【问题讨论】:
标签: doctrine-orm orm
有没有人知道有没有使用 Doctrine 而不使用 DQL 的快速方法来获取表中的所有记录。
是我遗漏了什么,还是你只需要在类中编写公共函数?
【问题讨论】:
标签: doctrine-orm orm
如果你有一个实体类(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();
【讨论】: