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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:09:03+00:00 2026-05-28T14:09:03+00:00

I have a list that is pulled from three tables, Department, Type and User.

  • 0

I have a list that is pulled from three tables, Department, Type and User.

Displayed like this:

Film 
student      Jimmy Stewart
faculty      Cary Grant

from actions.class.php

$this->departments = Doctrine_Core::getTable('Department')
        ->createQuery('a')
        ->orderBy('a.name')
        ->execute();

indexSuccess.php

<?php foreach ($departments as $dept): ?>
      <tr>
        <?php check_for_id() ?>
        <td colspan="4" class="displayDept" valign="top"><?php echo $dept->getName() ?></td>
    </tr>
    <tr>
    <?php foreach ($dept->getUsers() as $user): ?>
    <tr>
      <td class="displayInfo" valign="top"><?php echo $user->getType() ?></td>
      <td class="displayInfo" valign="top"><a href="<?php echo $user->getUrl() ?>" target="_blank"><?php echo $user->getUrl() ?></a></td>
      <td class="displayInfo" valign="top"><?php echo simple_format_text($user->getDescription()) ?></td>
    </tr>
    <?php endforeach; ?>
   <?php endforeach; ?>

However, this results in the foreach pulling all id’s from the department table leaving some empty rows under the Department display. Like this:

Photography
student      Keanu Reeves
faculty      Lawrence Fishburn

Drawing

Film 
    student      Jimmy Stewart
    faculty      Cary Grant

Painting

Sculpture

Can I remove the departments that do not have a user id?

UPDATE

If I am going to use a join, how do I call that in the actions? This is where I am so far, but none of my iterations are working:

$this->departments = Doctrine_Core::getTable('Department')
        ->createQuery('a')
        ->leftJoin('a.Users p')
        ->orderBy('a.name ASC')
        ->execute();

I’m not sure what it does though. I can understand the WHERE as it would be in traditional php, but I cannot follow the symfony syntax. Am I even close??

  • 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-28T14:09:04+00:00Added an answer on May 28, 2026 at 2:09 pm

    Why not do it in the query, department joined with users?

    UPDATE

    this is from the top of my head, but it should be something like this:

    $this->departments = Doctrine_Core::getTable('Department')
            ->createQuery('a')
            ->leftJoin('a.Users p')
            ->groupBy('a.id')
            ->having('COUNT(a.id) > 0')
            ->orderBy('a.name ASC')
            ->execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of images that are pulled from a database and loaded
I have a list that looks like (A (B (C D)) (E (F))) which
Hello I have this list that i am working on. When i move the
i have list of rows that user select and i want to delete them,
I have a specialized list that holds items of type IThing : public class
I have a ListView-like control that displays a list of items of various heights.
I have a view, that is of Inherits from System.Web.Mvc.ViewPage<P> . Type P has
I have two lists. First one is a list of Tasks pulled from an
I have a List that contains items, for example: 1) https:\\10.12.23\\ 2) https:\\12.23.12.25\\ 3)
I have one list that I want to take a slice of, reverse that

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.