Posted by Scott Auge on 11/14/74 11:21
I am looking for comments on something that lets me abstract database
updates in an object.
Lemme explain what I am thinking:
Lets say I have an object Person with...
SetFirstName()
SetLastName()
etc.
(Basically the goal is for the development team to use the objects and
not try to write to the database themselves.)
Well, what I am trying to avoid is when I call SetFirstName() and then
call SetLastName() the execution of two UPDATE statements. I would like
to combine it all into one single UPDATE or INSERT so I am not beating
up on the database.
I am thinking I would need to store the changes into variables local to
the class and then maybe calling a SendSQL() function or something like
that to generated SQL changes of the data to the database.
Something like:
$DB->query("BEGIN TRANSACTION");
// Person fools around with $DB
$Person->SetFirstName("Something");
$Person->SetLastName ("Something");
$Person->SendSQL();
// Another object fooling around with $DB
$AnotherOBj->SomeMethod ("Foo");
$AnotherOBj->SendSQL();
$DB->query ("COMMIT TRANSACTION");
Anyhow - opinions and experiences are welcome!
[Back to original message]
|