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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:22:48+00:00 2026-05-23T16:22:48+00:00

In CakePHP I am trying to save data in a subdocument like this: $mongo

  • 0

In CakePHP I am trying to save data in a subdocument like this:

$mongo = $this->User->getDataSource();
$mongo->update($this->User, array(
    array(
        '_id' => $tweep['User']['_id'],
        'Services._id' => $tweep['User']['Services']['_id']
    ),
    array('Services.$.following' => $following)
));

But obviously I am doing something wrong as it doesn’t work.

$following is an array that I would like to save under Services whith a specific id.

This is the datasource method:
https://github.com/ichikaway/cakephp-mongodb/blob/cake2.0/Model/Datasource/MongodbSource.php#L635

  • 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-23T16:22:49+00:00Added an answer on May 23, 2026 at 4:22 pm

    use updateAll() method instead of update().

    or

    use MongoDbCollection Object.
    https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-get-MongoObject-or-MongoCollection-object

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

Sidebar

Related Questions

Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
I'm trying to package up some data for the save() function in cakephp. I'm
I'm trying to get a CakePHP application to work. For this, I've set up
i am trying to create a Radio button using Cakephp like the one the
I am trying to make a simple redirector controller in CakePHP. I'd like the
I'm trying to get this loop to save a new record to the database
So I am trying to save a form with CakePHP. Its a fairly simple
I am trying to send data over to a cakephp (mvc) website, via $.post().
I'm trying to load , edit and save a record with CakePHP 2.0 but
I'm trying to create an account register page with CakePHP 2.0 where user needs

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.