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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:01:39+00:00 2026-05-21T12:01:39+00:00

I have three tables such as user, job and job_applied. user table has uid

  • 0

I have three tables such as user, job and job_applied. user table has uid , job table has jid and job_applied has uid and jid . I need to get job title, description, position of job table according to uid and jid of job_applied table.
I’m able to get values from below code, But i think this is the wrong way (crude way) .

$this->jobapplieds = $this->getUser()->getUser()->getJobApplieds();

foreach($jobapplieds as $ja)   
{    
    $c = new Criteria();

    $c->clearSelectColumns();

    $c->addSelectColumn(JobPeer::TITLE);

    $c->addSelectColumn(JobPeer::DESCRIPTION);

    $c->addSelectColumn(JobPeer::STATUS);

    $c->add(JobPeer::JID,$ja->getJid());

    $rs = JobPeer::doSelectRS($c); 

    while($rs->next())
    {
        echo $rs->getString(1); 
        print $rs->getString(2);
    }

    echo $ja->getAppliedAt();

}
  • 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-21T12:01:40+00:00Added an answer on May 21, 2026 at 12:01 pm

    If the current user has applied for 10 jobs, you currently do 10 + 1 queries (one to get all applications and then one per job). You can improve this in two ways:

    Instead of doing 10 queries in your loop, you can first collect all jid values in an array and then do an IN query, so you do 1 + 1 queries.

    $this->jobapplieds = $this->getUser()->getUser()->getJobApplieds();
    $jobapplieds_by_jid = array();
    foreach ($jobapplieds as $ja)
    {
        // If you can apply multiple times for the same job, this should be a second-level array
        $jobapplieds_by_jid[$ja->getJid()] = $ja;
    }
    
    $c = new Criteria();
    $c->add(JobPeer::JID, array_keys($jobapplieds_by_jid), Criteria::IN);
    $jobs = JobPeer::doSelect($c); 
    
    foreach ($jobs as $job)
    {
        echo $job->getTitle();
        echo $job->getDescription();
        echo $jobapplieds_by_jid[$job->getJid()]->getAppliedAt();
    }
    

    The other option is to do one query where you start with the job table, join it with the job_applied table, and set the uid of the job_applied table to your current user ID. This should execute only one query.

    $c = new Criteria();
    $c->add(JobAppliedPeer::UID, $this->getUser()->getUser()->getUid());
    $jobs = JobPeer::doSelectJoinJobApplied($c);
    foreach ($jobs as $job)
    {
        echo $job->getTitle();
        echo $job->getDescription();
        echo $job->getJobApplied()->getAppliedAt();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables: User, Employee and Worker. User table has one-to-zero-or-one relationship with
I have three tables, a user-table and two user-type tables. The user-type tables have
Let's say you have three tables named Item, Event, and Seat, constructed as such:
I have three tables as follows: table 1 is called Cat1, table 2 is
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three tables like that: Articles IdArticle Title Content Tags IdTag TagName ContentTag
I have three tables associated and am trying to do a simple search. User
I have a table User that stores user information - such as name, date
I have a table with three fields - userID, couponID, last_couponID. When the user
Overview: I have three tables 1) subscribers, bios, and shirtsizes and i need to

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.