任何人都可以解释Doctrine
框架
Symfony2
指令
1. $academicYear = $em->getRepository('ComAkSolutionsSmsUserBundle:AcademicYear')
->find($id);
2. public function manageAcademicClassAction($classId, Request $request)
{
$em = $this->getDoctrine()->getManager();
$academicClass = $em->getRepository('ComAkSolutionsSmsUserBundle:AcademicClass')
->find($classId);
$academicYear = $em->getRepository('ComAkSolutionsSmsUserBundle:AcademicYear')
->find($academicClass->getAcademicYearId());
3. $students = $em->getRepository('ComAkSolutionsSmsUserBundle:StudentProfile')
->findBySectionId($sectionId);
4. $teacherProfile = $em->getRepository('ComAkSolutionsSmsUserBundle:TeacherProfile')
->findOneByUser($user);
答案 0 :(得分:0)
find()是基本doctrine repository中按主键查找记录的方法。前两个示例是相同的,您只是查找不同的存储库。
您的第3和第4个示例是custom repositories并实现了自己的方法findBySectionId()和findOneByUser()。