machete
machete

Reputation: 1157

Doctrine 2.1 find entity by unique field

I want to find an entity by an unique (in this example the email) field.

User
id (int, pk)
email (string, not null, unique)
password (string, not null)

I know that there is findBy for repositories but since the email field is unique I don't want to use a repository as there always will be only one result.

Is this possible?

Upvotes: 1

Views: 245

Answers (1)

machete
machete

Reputation: 1157

It can be done by using findOneBy

Upvotes: 4

Related Questions