原则 - 检查是否存在基于字段的记录 [英] Doctrine - check if record exists based on field
本文介绍了原则 - 检查是否存在基于字段的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在symfony2中使用doctrine,我有一个简单的用户模型,其中包含以下字段:
Using doctrine in symfony2, i have a simple user model with the following fields:
Username
Email
Password
如何根据电子邮件地址加载模型?
How can I load the model based on email address?
推荐答案
$user = $this->getDoctrine()
->getRepository('YourBundle:User')
->findOneBy(array('email' => $email));
请阅读官方教义orm文档关于这个
这篇关于原则 - 检查是否存在基于字段的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文