Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Request #5790 Automatically determine insert/update for an object
Submitted: 2005-10-26 16:17 UTC
From: richtl at arscognita dot com Assigned:
Status: Open Package: DB_DataObject
PHP Version: 5.1.0 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-10-26 16:17 UTC] richtl at arscognita dot com
Description: ------------ The MyObjects library has a store() function that automatically determines whether an object should be inserted or updated depending on whether it exists in the database. I find I'm writing a log of "if this->find() then update else insert" sorts of structures. It would make sense to move this into the DB_DataObjects code. What I'm proposing is essentially, function store() { if( object exists in the database ) { // update it from object properties } else { // insert it as a new row } }

Comments

 [2005-10-28 01:15 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-02-05 23:10 UTC] mz+pear at dago dot de
Indeed, it may be a kind of useless implementing a lot of 'little' methods, but i'm also using Hibernate (as a database-abstraction for Java), which also provides this feature. At least every database-abstraction uses this behaviour. After thinking about why, it seems clearly to me now: it's a matter of fact, that abstraction layers are used to make things easier to programmers. They should also hide some 'internals' that aren't neccessary to know from him (I think, nobody wants to handle a floppy-disk-drive in the matter a operating system does, writing to /dev/fd0 is the easy way). In this case, the programmer wants to _persist_ data - in which way isn't that interesting for him, this should be decided by the database abstraction layer.