Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4013202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:20:31+00:00 2026-05-20T09:20:31+00:00

Using symfony framework, which code is best to query database table to check if

  • 0

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');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:20:32+00:00Added an answer on May 20, 2026 at 9:20 am

    The easist way, assuming you’re in a Doctrine_Table instance, which it appears you are is:

    $this->findOneByEmail($email);
    

    You shouldn’t need type if you’re using concrete inheritance because it will be added via DQL callback (assuming you have them enabled), but for completeness:

    $this->findOneByEmailAndType($email, 'newsletter');
    

    These will return the Doctrine_Record if it exists or null if it doesn’t.

    You can also use a count on your query:

    $exists = $this->createQuery('t')
        ->where('t.email = ?', $email)
        ->andWhere('t.type = ?','newsletter') // your probably don't need this
        ->count();
    

    This will return either the number of records that match the query. This a more efficient as it does not hydrate the results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've developed an application which uses the Symfony 2 framework. The application code resides
I am using a web application framework (Symfony 1.3.6), which follows the MVC pattern.
I'm building a site using symfony php framework. I have a link in my
I'm using symfony 1.4.3 Is there some way to render a sfWidgetFormChoice as an
I want to develop using a framework called Symfony but I do not have
I am using sfOpenID plugin for Symfony, which doesn't support OpenID 2.0. That means,
Good day, I have an application written using the Symfony framework. The application works
Ok, so here's the issue. Currently I'm using the symfony framework to develop a
I would like to start using TDD in my PHP projects using Symfony 1.4
I'm using PHP with the Symfony framework for my web projects. The framework allows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.