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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:34:20+00:00 2026-06-05T16:34:20+00:00

I have two tables, a user table and a application table: User id username

  • 0

I have two tables, a user table and a application table:

User
    id
    username
application
    id
    user_id
    ...

To get the application I would like to be able to select the application by either the application id or the username. To get the application by the app id was simple enough with $row = $this->fetchRow("id = $id"); but I’m not sure how to go about getting the application by username. Below is the relevant code I currently have in my model.

protected $_referenceMap = array (
    'User' => array (
        'columns'           => 'user_id',
        'refTableClass'     => 'Application_Model_DbTable_User',
        'refColumns'        => 'id'
    )
);

public function get_application($id) {
    if(is_numeric($id)) {
        $row = $this->fetchRow("id = $id");
    } else {
        //get application by username
    } 
    return $row->toArray();
}
  • 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-05T16:34:22+00:00Added an answer on June 5, 2026 at 4:34 pm

    If I understand your question correctly, I think you just want:

    $userRow = array_shift($this->findDependentRowset('User'));
    

    Edit: Wait, no that’s not right. That finds the user once you’ve already gotten the right application.

    Assuming you have the reverse relationship defied as well, you should be able to do this:

    $userTable = new Application_Model_DbTable_User();
    $userRow = $userTable->fetchRow('username = ?' , $username); // or whatever
    $applicationRow = $userRow->findParentRow('Application');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables user table user_id | name | 1 | peter |
I have two tables user and log. I would like to join the user
I have two tables. One user table and one table in which results are
I have two tables in my database: user and media_contact . The media_contact table
I am facing a situation and need help. I have two tables: user: user_id
Given my two db tables aliases and subscriber have entries like this: aliases.username =
In SQL Server 2008 I have two tables. One table for users: id_user -
I have two tables user and email. One user can have multiple emails so
I have two sql tables for user login, store and retrieve data according to
I have the following two tables: auth_user id username is_active (boolean) ... useprofile_userprofile id

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.