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 169993

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:43:45+00:00 2026-05-11T12:43:45+00:00

Using cakephp, I have a generic address table, which I want to link to

  • 0

Using cakephp, I have a generic address table, which I want to link to customers, vendors, contacts. most of the tables only have a 1 to 1 relationship, but I want my customers table to have 2

perhaps for clarification: I have a customers table

id, int mailing_address_id, int billing_address_id, int 

and an addresses table

id,int addr, varchar city, varchar etc.... 

Now I know I could put a customer_id in the addresses table. But I don’t want to do that because I have a vendors table, and contacts table, and other tables that all are going to use the addresses table. the customer_id would not really be relavant to those other tables.

I’d like the Customer model to automatically link in the two addresses

  • 0 0 Answers
  • 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. 2026-05-11T12:43:46+00:00Added an answer on May 11, 2026 at 12:43 pm

    Follow Travis Leleu’s suggestion – because it’s a good idea, regardless.

    Then add an enum field to the Addresses table called table_id. The value of the table_id field could be ‘customer’, ‘vendor’, ‘contact’, and whatever other tables would link to the addresses table.

    Also include a single foreign key called entity_id. This foreign key would be the primary key of the corresponding customer, vendor, or whatever.

    When you, for example, want the billing address for a certain vendor, add in the $conditions array:

    'Address.entity_id'=>'123456' 'Address.table_id'=>'vendor' 'Address.type'=>'billing' 

    With this set-up you could have as many tables as you want referencing the Addresses table.

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

Sidebar

Ask A Question

Stats

  • Questions 80k
  • Answers 80k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Add parenthesis: SELECT TOP (@NumberOfResultsToReturn) * May 11, 2026 at 4:22 pm
  • Editorial Team
    Editorial Team added an answer The following code returns an IEnumerable object that allows you… May 11, 2026 at 4:22 pm
  • Editorial Team
    Editorial Team added an answer I think you might have this a bit backwards. Port… May 11, 2026 at 4:22 pm

Related Questions

I'd like to work on a BB Code filter for a PHP website. (I'm
This is actually a problem that I've already solved, but I suspect that there
I'm using cakePHP and I want to add a First and Last name column
I'm using CakePHP for a small web app and on one form page there's

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.