Using symfony framework, which code is best to query database table to check if entry is already there?
I need query like this:
$q = $this->createQuery('t')
->where('t.email = ?', $email)
->andWhere('t.type = ?','newsletter');
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easist way, assuming you’re in a Doctrine_Table instance, which it appears you are is:
You shouldn’t need
typeif you’re using concrete inheritance because it will be added via DQL callback (assuming you have them enabled), but for completeness:These will return the Doctrine_Record if it exists or null if it doesn’t.
You can also use a count on your query:
This will return either the number of records that match the query. This a more efficient as it does not hydrate the results.