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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:23:10+00:00 2026-06-17T05:23:10+00:00

I have a hasMany through (the join model) which is not saving, but when

  • 0

I have a hasMany through (the join model) which is not saving, but when reading, it works naturally.

I will try to provide as much detail as possible, so bear with me. Please note I am trying to save a new user paired with quantities of existing products, and I am not wanting to add new products in this save.

Database Tables: users, products, subscribed_users

Table structure of joining table: id, user_id, product_id, quantity, created, modified

User.php

public $hasMany = array(
   'SubscribedUser'
);

Product.php

public $hasMany = array(
   'SubscribedUser'
);

SubscribedUser.php

class SubscribedUser extends AppModel {
   public $belongsTo = array(
       'User', 'Product'
   );
}

Data array I am trying to save from within the UsersController.php

Array (
    [User] => Array (
        [username] => asdf
    )
    [SubscribedUser] => Array (
        [0] => Array (
            [product_id] => 50f1ef25-6884-44cf-80e4-bd346f01a4c2
            [count] => 12
        )
        [1] => Array (
            [product_id] => 50f1f1d6-89b4-4ade-961f-c1a06f01a4c2
            [count] => 12
        )
    )
)

Using $this->User->SubscribedUser->saveAll($data); I have the User properly saved, but my subscribed_users table only has one row (as you can see from my above data, there should be two) and it contains missing data. There is no product_id, and the count number is 0.

I am not sure what I am missing here. Thoughts?

  • 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-17T05:23:11+00:00Added an answer on June 17, 2026 at 5:23 am

    The problem was I was using $this->User->SubscribedUser->saveAll() and not $this->User->saveAll()

    My problem is now solved with this resolution.

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

Sidebar

Related Questions

I have hasMany Through table which is Chats table with Chat model and I'm
I have a many-to-many relationship set up through a join model. Essentially, I allow
Once again, I have my form_for for my Order model, which has_many :services, :through
What I have: A HABTM C HABTM A through join table B A hasMany
I have a join model in a HABTM relationship with a through association (details
I cannot get the associated Model data using hasMany through (Join Model) association. I'm
I have Product model and it has many categories with a has_many :through association
I have Lineup and Piece models joined by piece_lineup model (has many through). I
I have an Organization model that has_many users through affiliations. And, in the form
I have the following :has_many, :through association for my models: Group Model: has_many :group_users

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.