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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:23:46+00:00 2026-05-27T05:23:46+00:00

I have a table applications with a HABTM relationship with another table named users

  • 0

I have a table applications with a HABTM relationship with another table named users. The table linking these 2 together is applications_users.

Now, with this code,

$data = array(
    'Application' => array(
        'id' => 123
    ),
    'User' => array(
        'application_id' => 123,
        'user_id' => 456
    )
);
$this->Application->saveAll($data);

I’m getting the expected lines in my tables, but I’m also getting a strange line in applications_users that contains 123 in both applicaiton_id and user_id.

Any idea where this line does come form ? And how to avoid it ?

  • 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-27T05:23:47+00:00Added an answer on May 27, 2026 at 5:23 am

    Cake magic put it there!
    And it is supposed to as it is, as you said, the link table between applications and users tables.
    The HABTM relationship is a “many-to-many” relationship that need a third table to link records from the two tables.

    The key code here is this:

    'application_id' => 123,
    

    that tell cake that the user belongs to the application with the id=123 and also that the user with the id=123 has the application with id (application_id)=123.

    If you don’t want to link the two, remove the above line.

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

Sidebar

Related Questions

Many applications have grids that display data from a database table one page at
In one of my applications I have a 1gb database table that is used
I have a table like this: Application,Program,UsedObject It can have data like this: A,P1,ZZ
I am writing a turbogears2 application. I have a table like this: class Order(DeclarativeBase):
I am working on an auction web application. Now i have a table with
i have an Applications table and a Resources tables. Since many resources can work
I have a 'users' table with two columns, 'email' and 'new_email'. I need: A
I have table Candidates with id (primary key) and application_counter and table Applications with
I have one table 'Students' and one table 'Applications'. Each student can apply for
I have two tables applications and leads application table submitDate | fName | lName

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.