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

  • Home
  • SEARCH
  • 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 8229987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:58:58+00:00 2026-06-07T16:58:58+00:00

Perhaps an example would best describe my problem: Schema: Referral: actAs: { timestampable: ~

  • 0

Perhaps an example would best describe my problem:

Schema:

Referral:
  actAs:                            { timestampable: ~ }
  columns:
    id:                             { type: integer, primary: true, notnull: true, autoincrement: true, unique: true }  
    other_stuff:                    { type: string }  
    reasonCode:                     { type: integer }    
  relations:   
    ReasonCode:                     { local: reasonCode, foreign: id, foreignAlias: ReasonCodes }  

ReasonCode:
  columns:
    id:                             { type: integer, primary: true, notnull: true, autoincrement: true, unique: true }
    description:                    { type: string }

Query (referralTable.class.php):

    public function getObjectByReferralId($id){
        $q = Doctrine_Query::create()
            ->select('*')
            ->from('referral_submissions')
            ->where('referral_id=?', $id)
            ->fetchOne();
        return $q;   
    }

Call in template:

<?php 
$id = <source of id>;
echo Doctrine_Core::getTable('referral')->getObjectByReferralId($id)->getReasonCode();
 ?>

The above call in the template to get the reasoncode returns the “description” stored in the ReasonCode table, not the stored id in the Referral table. I need the actual id, not the joined description. What am I missing?

  • 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-07T16:58:59+00:00Added an answer on June 7, 2026 at 4:58 pm

    It’s confusing because you named your foreign key with the name of your relation. So when you think you are getting the key, you fetch the relation. And I guess Doctrine do not retrieve the primary key since there is only one field in your ReasonCode table, so it returns the description field.

    Try with :

    Doctrine_Core::getTable('referral')
      ->getObjectByReferralId($id)
      ->get('reasonCode');
    

    By the way, you also can retrieve the id using the relation:

    Doctrine_Core::getTable('referral')
      ->getObjectByReferralId($id)
      ->getReasonCode()
      ->getId();
    

    I think you should define your foreign key like : reason_code_id instead of reason_code. Then your schema will become:

    Referral:
      actAs:                            { timestampable: ~ }
      columns:
        id:                             { type: integer, primary: true, notnull: true, autoincrement: true, unique: true }  
        other_stuff:                    { type: string }  
        reasonCode_id:                  { type: integer }    
      relations:   
        ReasonCode:                     { local: reasonCode_id, foreign: id, foreignAlias: ReasonCodes } 
    

    And you will be able to retrieve the id using:

    Doctrine_Core::getTable('referral')
      ->getObjectByReferralId($id)
      ->getReasonCodeId();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Perhaps easiest to explain with an example: $ echo '\&|' \&| $ echo '\&|'
Perhaps any of you can help me with this anoying problem. I have long
Perhaps I'm misunderstanding the technical definition of lower bound but I would expect if
Looking for advice (perhaps best practice). We have a MS Word document (Office 2007)
Perhaps I am over thinking this, but I would like to understand the purpose
I would like to represent dynamic images in an email. For example with the
I'll try to explain my query in the best of my ability. I would
I'm wondering what would be the best way to check if a file is
Perhaps you can help me find this in the docs. I'm using pound-quote to
Perhaps this is an effect of installing the new 4.5 beta, but my simulator

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.