我在 Symfony2 中有一个原始查询
$sql = "SELECT * FROM Content
JOIN ContentLearningAreas ON Content.id = ContentLearningAreas.content_id
JOIN LearningArea ON ContentLearningAreas.learning_area_id = LearningArea.id
WHERE ContentLearningAreas.learning_area_id = {$id} AND Content.active = 1";
$stmt = $this->getEntityManager()->getConnection()->prepare($sql);
$stmt->execute();
return $stmt->fetchAll();
这很好用,但我希望将结果转换为内容实体,以便它们的功能仍然有效。
Jake\NameOfBundle\Entity\Content
如何才能做到这一点?
编辑
看来这是使用 PDO 而不是 Doctrine 或 Symfony2。