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 6468279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:52:30+00:00 2026-05-25T05:52:30+00:00

I apologize for the beginner question, but I’m struggling with what seems should be

  • 0

I apologize for the beginner question, but I’m struggling with what seems should be a simple query. I can get it to work perfectly in MySQL, but can’t get it to work in my symfony application. Essentially, this is all I’m trying to do:

SELECT * 
FROM benefits b
WHERE b.company_id = X

X = 
SELECT id
FROM company c
WHERE c.user_id = ($this->getUser()->getGuardUser()->getId())

I’ve tried many join statements but still can’t get it to work with the result I want, such as:

public function executeIndex(sfWebRequest $request)
{
$this->benefitss = Doctrine_Core::getTable('benefits')
->createQuery('b')
->where('user_id = ?', '$this->getUser()->getGuardUser()->getId()')
->leftJoin('b.Company c')
->andWhere('c.user_id = ?', '$this->getUser()->getGuardUser()->getId()')
->execute();      
}

Here’s my condensed schema:

Benefits
 columns
  id
  user_id
  company_id
  name
 relations
  User {class: sfGuardUser}
  Company 

Company
 columns
  id
  user_id
  name
 relations
  User {class: sfGuardUser}

sfGuardUser
 columns
  id

also of note: the user is not assigned a company_id b/c not all users will have companies according to my user definitions.

Any help for this wretched beginner would be much appreciated. 🙂

Update 8/27/11:

This gets the results I want:

$this->benefitss = Doctrine_Core::getTable('benefits')
->createQuery('b')
->leftJoin('b.Company c')
->Where('c.user_id = ?', '1')
->execute();      

Where the ‘1’ needs to be the current user’s id. But when I change the where clause to:

->Where('c.user_id = ?', '$this->getUser()->getGuardUser()->getId()')

I get no results.

Any ideas?

  • 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-25T05:52:30+00:00Added an answer on May 25, 2026 at 5:52 am

    I got it figured. Here’s how (I’m obviously a beginner):

        $this->benefitss = Doctrine_Core::getTable('benefits')
        ->createQuery('b')
        ->leftJoin('b.Company c')
        ->Where('c.user_id = ?', $this->getUser()->getGuardUser()->getId())
        ->execute();      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I apologize if this question was already asked but I can't seem to find
I apologize if this is a really beginner question, but I have not worked
Python beginner here, so I apologize if this question has a simple answer. (I
I apologize for asking such a generalized question, but it's something that can prove
I apologize for such a beginner question, but I'm stuck. I'm starting learn web
I'm a total beginner so I apologize if this question is elementary. I have
I apologize for this seemingly relatively simple task that I can't figure out. I
I apologize for the newb question but have not found a solution online. I
I apologize for asking such a dumb question but my linux server is stuck
I apologize in advanced if this is somewhat of a noob question but I

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.