Quantcast

Saving entities (only the changed columns)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Saving entities (only the changed columns)

Wesley Overdijk
Imagine this entity: 
$id = 1; 
$name = 'some name'; 
$credits = 3000; 
$email = '[hidden email]'; 

I can load this entity with: $mapper->findBy(Name/Email)($value); 

And I can store this entity back into the database. However, I can not find a way to store this entity without re-storing every value (since my entity does not contain the originals). 

In my opinion it is slower to perform an update on every column, but next to my opinion it could be a security risk if for example the credits became less just after loading the entity. If I change the email, store it back into the database the credits are back to the old value. 

Is there maybe a sample, or another aproach on how to do this properly without too much hassle? 

Regards 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Saving entities (only the changed columns)

blue_software_lucasm
This post has NOT been accepted by the mailing list yet.
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Saving entities (only the changed columns)

SocalNick
In reply to this post by Wesley Overdijk
You should probably read about Doctrine's locking support. Even if you don't decide to use Doctrine, you will have to implement something like this:

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html#locking-support


Nicholas Calugar
http://socalnick.github.com


On Thu, Sep 13, 2012 at 7:31 AM, Wesley Overdijk <[hidden email]> wrote:
Imagine this entity: 
$id = 1; 
$name = 'some name'; 
$credits = 3000; 
$email = '[hidden email]'; 

I can load this entity with: $mapper->findBy(Name/Email)($value); 

And I can store this entity back into the database. However, I can not find a way to store this entity without re-storing every value (since my entity does not contain the originals). 

In my opinion it is slower to perform an update on every column, but next to my opinion it could be a security risk if for example the credits became less just after loading the entity. If I change the email, store it back into the database the credits are back to the old value. 

Is there maybe a sample, or another aproach on how to do this properly without too much hassle? 

Regards 

Loading...