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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:06:53+00:00 2026-05-28T22:06:53+00:00

Let’s suppose I retrieve an entity $e and modify its state with setters: $e->setFoo(‘a’);

  • 0

Let’s suppose I retrieve an entity $e and modify its state with setters:

$e->setFoo('a');
$e->setBar('b');

Is there any possibility to retrieve an array of fields that have been changed?

In case of my example I’d like to retrieve foo => a, bar => b as a result

PS: yes, I know I can modify all the accessors and implement this feature manually, but I’m looking for some handy way of doing this

  • 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-28T22:06:54+00:00Added an answer on May 28, 2026 at 10:06 pm

    You can use
    Doctrine\ORM\EntityManager#getUnitOfWork to get a Doctrine\ORM\UnitOfWork.

    Then just trigger changeset computation (works only on managed entities) via Doctrine\ORM\UnitOfWork#computeChangeSets().

    You can use also similar methods like Doctrine\ORM\UnitOfWork#recomputeSingleEntityChangeSet(Doctrine\ORM\ClassMetadata $meta, $entity) if you know exactly what you want to check without iterating over the entire object graph.

    After that you can use Doctrine\ORM\UnitOfWork#getEntityChangeSet($entity) to retrieve all changes to your object.

    Putting it together:

    $entity = $em->find('My\Entity', 1);
    $entity->setTitle('Changed Title!');
    $uow = $em->getUnitOfWork();
    $uow->computeChangeSets(); // do not compute changes if inside a listener
    $changeset = $uow->getEntityChangeSet($entity);
    

    Note. If trying to get the updated fields inside a preUpdate listener, don’t recompute change set, as it has already been done. Simply call the getEntityChangeSet to get all of the changes made to the entity.

    Warning: As explained in the comments, this solution should not be used outside of Doctrine event listeners. This will break Doctrine’s behavior.

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

Sidebar

Related Questions

Let's aggregate a list of free quality web site design templates. There are a
Let's say there is a graph and some set of functions like: create-node ::
Let's suppose I have a Discussion model, and that a discussion can be tagged.
Let's suppose I have this piece of code. foreach(string value in myList) { string
Let's suppose I've got a 2D vector template class: template<typename T> class Vec2 {
Let's say the rule is as follows: .largeField { width: 65%; } Is there
Let's say there is a list of List<UInt32> Thus, : 12|12 23|33 33|22 11|22
Let's consider a simple grid, where any point is connected with at most 4
Let's say you create a wizard in an HTML form. One button goes back,
Let's say I'm building a data access layer for an application. Typically I have

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.