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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:12:38+00:00 2026-06-06T15:12:38+00:00

Basically try to do the same as: UPDATE table SET column3 = column1 +

  • 0

Basically try to do the same as:

UPDATE table SET column3 = column1 + column2;

In the Doctrine2’s ODM QueryBuilder – is something like this possible with out MapReduce? I have a sharded collection, so I need to use the QueryBuilder in order to search by my compound shard key.

Simplified exmaple:

$visit = $this->dm->createQueryBuilder('Visit')
   ->findAndUpdate()
   ->field('site')->equals( $site )
   ->field('timeStamp')->equals( $ts )
   ->field('_id')->equals( $id )
   ->update()
   ->field('column3')->set( 'column1 + column2' );

Unfortunately, that would set column3 to the string “column1 + column2”. Any ideas?

  • 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-06T15:12:39+00:00Added an answer on June 6, 2026 at 3:12 pm

    Unfortunately, neither $inc nor $set will help here, as they expect literal values. I also don’t think findAndModify would help, since it uses the same modifier object as update().

    I don’t think map/reduce is appropriate either, as that isn’t intended to modify the documents being mapped.

    If you weren’t in a sharded infrastructure, you could use db.eval() to fetch and update the object atomically; however, that isn’t an option.

    I would suggest splitting this into two queries. First, find the object by its site, timestamp and _id. You can limit the fields returned to column1 and column2. Then, issue an update with the same criteria plus a match on column1 and column2, and set column3 to their sum. The addition of column1 and column2 to the update criteria will ensure you don’t inadvertently store an invalid if those fields were changed between the find and update queries. And effectively, your update query becomes idempotent.

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

Sidebar

Related Questions

I' still newby to this so I'll try to explain what I'm doing. Basically
Basically I'd be looking to implement a method like this. IQueryAble GetQuery<T>(Entities db) or
I'll try to explain this logically as best as I can. Basically I have
Basically I am trying the same as this guy: How can I tell proguard
Basically I would like to store the address of a pointer in a buffer.
Basically I am looking for a win32 method to invoke in C# to set
Basically, I would like to decode a given HTML document, and replace all special
I have a news table and I would like to implement custom ordering. I
Following this post which I posted some time ago, I now get the same
Basically, I have a problem with replace() function in MySQL (via phpMyAdmin). One table

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.