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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:38:15+00:00 2026-06-09T06:38:15+00:00

I have a function Company Profile has a relationship HABTM to Users Controller with

  • 0

I have a function Company Profile has a relationship HABTM to Users Controller with a joint table companies_users my functions is

ublic function company_profile(){
//$logo= $this->Upload->upload('/img/company_logo', $this->data['logo']['a'],null, array('image/jpeg', 'image/jpg', 'image/png'));
$log = $this->Auth->User('id');
    // retrieve the data of the currently logged in user
$user = $this->User->find('first',array(
            'conditions'=>array('User.id'=>$log),
            'recursive'=>1
));
    //pr($user);exit();
    if($this->request->is('post') || $this->request->is('put')){
        //pr($this->request->data);exit;
        //pr($this->data);exit();
        if(isset($user['Company']) && !empty($user['Company'])){
        $newcompany = array();
        $this->User->Company->id = $user['Company'][0]['id'];
        $newcompany['Company'] = $this->data['Company'][0];
        $newcompany['Company']['id'] = $user['Company'][0]['id'];
        //pr($newcompany);exit();
        $this->User->Company->save($newcompany);
        }else{
        $this->User->Company->create();
        $newcompany = array();
        $newcompany['Company'] = $this->data['Company'][0];
        $newcompany['Company']['user_id'] = $log;
        pr($newcompany);exit();

        //newlogo = $this->request->data;
        //$newlogo['Company']['logo'] = $logo['urls']['0'];
        $this->User->Company->save($newcompany);
        //pr($newcompany);exit();
        $this->Session->setFlash('Company Profile Saved Successfully.');
        $this->redirect('/users/dashboard');

        }



    }else{
    $this->request->data = $this->User->read(null, $log);
    }
$this->loadModel('Category');
$categories = $this->Category->find('list');
$this->set(compact('user','categories'));

}

why is it it doesn’t save on the joint table ? please help me on how it will be save in the joint table currently i have this array

Array
(
[Company] => Array
(
[id] =>
[category_id] => 1
[name] => Infoperks Solutions
[description] => Web development
[user_id] => 1
)

)

  • 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-09T06:38:16+00:00Added an answer on June 9, 2026 at 6:38 am

    Using 'deep' => true you can save the joined table data provided that you specified the model associationship. You can try to save the joined data using the following syntax:

    $this->User->save($newcompany, array('deep' => true));
    //instead of
    //$this->User->Company->save($newcompany);
    

    This link will surely help you to save your HABTM associated data.
    Kindly ask if it not worked for you.

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

Sidebar

Related Questions

My company would dearly like to have an iPhone app which, among other functions,
I'm using intelliJ IDEA 9. It has a function to make a copyright profile
Stack Overflowers: I have a search function on my company's website (based on .NET
I have a function in my company's site that uses the cgi.remote_host variable to
The coding standards at my company have changed such that the function declaration void
I have a function that returns groups(clusters) from a table.. create function dbo.ftAllClusters() returns
I have controller and it has following code: class Company_ModuleName_NameController extends Mage_Core_Controller_Front_Action { public
I have a Backbone.Model named Company . My Company model has an Employees Backbone.Collection
I have a web-site that has a hosting at some popular hosting company. The
I have the following code: var Company = function(app) { this.crypto = require('ezcrypto').Crypto; var

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.