You are here: Abstracting SQL Statements In An Object « PHP Programming Language « IT news, forums, messages
Abstracting SQL Statements In An Object

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!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация