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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:34:28+00:00 2026-06-06T00:34:28+00:00

I am trying to pull a specific set of records from a table called

  • 0

I am trying to pull a specific set of records from a table called Faculty, by retrieving a specific parameter from another table. I am getting the id from the sfGuard User, then retrieving the record from the ID. From there I would like to pull out the department title from that table and display only records from Faculty with that department title.

This is what I have in my actions.class:

$userId = $this->getUser()->getGuardUser()->getId();
$userRecord = Doctrine_Query::create()
        ->from ('sfGuardUser s')
        ->where("s.id = '$userId'")
        ->limit('1')
        ->execute();
$userDept = $userRecord['department_title'];        
$this->facultyAdminFind = Doctrine_Query::create()
        ->from ("Faculty a")
        ->where("a.notables LIKE ?", "%$userDept%")
        ->execute();

After doing some troubleshooting, I know I am pulling the correct ID and the correct record from sfGuardUser table. I just can’t seem to pull the department title from the sfGuardUser record.
The loop is coming up with nothing.

If I change $userDept = $userRecord[‘department_title’]; to $userDept = “Engineering”;

Update to questions below:

I am getting the userID, then asking for the department_title of that ID. I can get the id using getGuardUser(), but not ‘department_title’ right? If so, what would that syntax look like?

I am sure there is a department title and there are no misspellings. I actually worked from this backwrds to verify all variables that were being pulled

First I did this:

$this->facultyAdminFind = Doctrine_Query::create()
        ->from ('sfGuardUser s')
        ->where("s.id = '$userId'")
        ->limit('1')
        ->execute();

which returned the correct record in the loop and I was able to use $item[‘department_title”] in the template to call the department title correctly. So I know I am getting the correct userID and calling the correct record into $userRecord.

Also, inside Faculty::notables there are strings with Engineering. That is why I did this:

$userDept = "Engineering";

And I was able to get a result of all records with Engineering in notables.

This is what I found that works:

Per ProdigitalSon I was able to look at the model and figure out how to pull the dept title from the user table. This is working.

$userId = $this->getUser()->getGuardUser()->getDepartmentTitle();
    $this->facultyAdminFind = Doctrine_Query::create()
            ->from ("Faculty a")
            ->where("a.notables LIKE ?", "%$userId%")
            ->execute();

UPDATE:

I learned you should not modify the sfGuard schema because if you update the plugin, you would lose the specialized schema. I have added a new class in the main schema, and have a working association between sf_guard_user and department_title.

The issue is I am back to square one with trying to get the department_title from the array.
Here is the added schema:

MyUserProfile:
  columns:
    id: { type: integer, primary: true, autoincrement: true }
    sf_guard_user_id: { type:integer }
    department_title: { type: string(255) }
    # ... other column definitions
  relations:
    User:
     class: sfGuardUser
     foreignType: one
     foreignAlias: Profile
     local: sf_guard_user_id
     onDelete: CASCADE

And this is the query that should work (in my head).

//pulls department limited records for faculty admin
    $userId = $this->getUser()->getGuardUser()->getId();
    $usergetDept = Doctrine_Query::create()
            ->from('MyUserProfile d')
            ->where("d.sf_guard_user_id = '$userId'")
            ->execute();

    $userDept = $usergetDept['department_title'];
    $this->facultyAdminFind = Doctrine_Query::create()
            ->from ("Faculty a")
            ->where("a.notables LIKE ?", "%$userDept%")
            ->execute();

This is pulling every record, not just the ones with the department_title. Could I do this easier with a multiple join maybe?

  • 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-06-06T00:34:29+00:00Added an answer on June 6, 2026 at 12:34 am

    Firs thing that stands out is why are you querying for the user when you already have the user. You dont need to query sfGuardUser again you already have that record from calling myUser::getGuardUser().

    So the next thing is are you sure the record youre working with has a department_title property set? Are you sure you didnt mispell the column name either in the schema or in the snippet code? And are us sure that the value in the sfGuardUser::department_title youre working with does in fact match some records in Faculty::notables?

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

Sidebar

Related Questions

im having some difficulty trying to pull out a specific value from a cookie.
I am trying to pull excerpts and custom fields from specific posts, I have
So, I'm trying to pull all photos of a specific user's account via the
I'm trying to pull data from the YouTube API into a local MySQL table.
I am trying to create several models that all pull from the same table.
I'm trying to pull out page source from a set of pages and run
I'm trying to pull out specific elements from results from the Data Science Toolkit
I am trying to pull posts from a specific month that has been clicked
Just trying to pull off some SMART info from connected Hard Drives on any
I am trying to pull an LDAP jpegPhoto attribute from an openLDAP server using

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.