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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:53:31+00:00 2026-06-05T00:53:31+00:00

I have a situation where, for external reasons, I have to directly save join

  • 0

I have a situation where, for external reasons, I have to directly save join records rather than saving them as part of a join. Here’s what I mean:

  • I have a Firm model whose data is pulled from an external source.
  • I have a County model in my app database
  • I have a counties_firms join table that I use to associate those external firms to counties.

Because of what lives where, I’m not editing a Firm model nor am I editing a County model. I’m really just editing the associations. I have a Firm model to encapsulate anything I need to do with Firm data and one of these methods is Firm::saveCounties( $data ). It:

  • Accepts incoming data that includes the firm id and the county ids that should be associated.
  • Deletes all existing join records for that county
  • Attempts to save all of the new join records.

What I’m finding is that only the last county record is saved. Here’s the incoming data:

Array
(
    [0] => Array
        (
            [firm_id] => 13
            [county_id] => 4fa16e24-a25c-4523-8a9e-7d1d147402e8
        )

    [1] => Array
        (
            [firm_id] => 13
            [county_id] => 4fa16e27-ccd0-4f22-97da-7d1d147402e8
        )

    [2] => Array
        (
            [firm_id] => 13
            [county_id] => 4fa16e4a-68f8-4fb1-95bb-7d1d147402e8
        )

)

Given that data, I’m creating an on-the-fly association between Firm and CountiesFirm and attempting to $this->CountiesFirm->saveAll( $data ).

As I mentioned, only the last of the 3 county associations in this example is getting saved. Any idea what I might be missing?

Thanks.

  • 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-05T00:53:32+00:00Added an answer on June 5, 2026 at 12:53 am

    I believe you are missing a level in your array… it should look something more like this…

    Array(
        'CountiesFirm' => array(
            [0] => Array
            (
                [firm_id] => 13
                [county_id] => 4fa16e24-a25c-4523-8a9e-7d1d147402e8
            )
            [1] => Array
            (
                [firm_id] => 13
                [county_id] => 4fa16e27-ccd0-4f22-97da-7d1d147402e8
            )
            [2] => Array
            (
                [firm_id] => 13
                [county_id] => 4fa16e4a-68f8-4fb1-95bb-7d1d147402e8
            )
        )
    )
    

    Try that and let me know you results

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

Sidebar

Related Questions

I have a situation where my main SWF file loads many external SWF files.
I have the following situation. Im getting data from an external system in the
I have quite unique situation. Here is my scenario: 4 thumbnails linking to the
I have a unique situation here. Essentially, I have an absolutely positioned block of
I'm conflicted on this one. Here's the situation - I have a bunch of
I have this situation - PhoneGap app running in Android. It uses external API
Let me explain my situation. I have a program who reads an external connection
So, here's my situation : I have a complete app set up with CodeIgniter.
I have a situation in Java where I have an external device that I
I have the following situation: I have a windows service that loads many external

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.