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! 1 1558
Scott Auge wrote: 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!
Scott,
Generally, classes do not access the database unless specifically requested.
You might have four class members, for instance - fetch(), update(), insert()
and delete(). Each does its respective operations based on the data in the
current object (fetch() usually requires a key).
Another common class is the list class, which fetches an array of objects based
on select criteria.
But no, you do NOT want to update the database every time you issue a
GetFirstName() or SetFirstName(). The former needlessly requires access to the
database, and the latter may update the database when you don't want it updated
(i.e. change the name - but verify the change with the user before actually
updating the database).
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Scott Auge |
last post by:
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()
|
by: John Thorner |
last post by:
Hi,
I am creating a new thread for each of the connections to the server:
public class Node_C
{
....
while (listening) {
Socket client_socket = server_socket.accept();
Node_CThread node = new Node_CThread(client_socket);
|
by: dmbkiwi |
last post by:
I am new to this group, and relatively new to python programming, however,
have encountered a problem I just cannot solve through reading the
documentation, and searching this group on google.
I have written a theme in python for the superkaramba theme engine on kde
(see http://netdragon.sourceforge.net - if you are a kde/linux user, it is
a great visual applet engine). I have uploaded it to www.kdelook.org for
others to download and...
|
by: Tom D |
last post by:
I'm rewriting a database interface that our company currently has.
Currently it's using the Pear::DB interface, but we found that that was
introducing a bit too much overhead. I'm rewriting the interface to use
mysqli. Most of what the interface does is to simplify getting results in
the form of arrays (ordered and associative). Most of the code using the
interface used sql queries with placeholders and parameters. For that
reason I'd...
|
by: Frank Rizzo |
last post by:
I have an app that has to connect to various data sources (ms sql server,
sybase, etc...). For this reason I have OdbcConnection, OleDb Connection and
SqlClient objects. When an error happens, I want a single procedure to
handle the error from all the connection types by passing the either the
SqlException, OdbcException or OleDbException.
Unfortunately the object SystemException, that these exceptions have been
derived from, does not...
| |
by: nevin |
last post by:
Hi all,
I'm looking at the Amazon web services and get them to work fine. But on any
given call I want to be able to use either the US or the EU schemas which
are in the project as two different web references.
so basically I would like to be able to abstract the objects in each web
service so that I can instantiate either one and pass it to a handler which
can work with either.
Basically the same as you do for two objects inherited...
|
by: Tim Barnes |
last post by:
I am going through a revision of my product where I am trying to
abstract out the data access layer, where I have traditionally just
dragged/dropped data adapters and generated datasets using Visual
Studio on my web forms. I am using the following document as a guide:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/BOAGag.asp
The problems that I am seeing are that I am getting empty result sets,
even tho db...
|
by: Full Decent |
last post by:
Hey all!
I've been using PHP for a while and I'm hearing that I should look into
using it OO. I'm looking into making changes to the program Camera Life
(http://fdcl.sf.net). I want to abstract the connection to the database
which is currently MYSQL and maybe implement another database, or just
leave it open for addition. If I get lucky and get the hang of this,
I'd also like to abstract calls to GD.
So firstly, is there a good...
|
by: |
last post by:
Hi. This is a a semi-newbie question about how to store arbitrary
information about my apps
such that I can code quickly, mimizing complexity and the number of things I
have to hold in my brain. I am going to describe the scheme I'm using, and
then
I'm going to describe another scheme that may be more OO but that I have not
tried.
I'm hoping someone vastly smarter and more experienced than me will critique
this
and/or tell me a yet...
|
by: =?Utf-8?B?QVRT?= |
last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g.
Please help,
I'm trying to write an ASP page to use ADO to run a long query against an
Oracle 10g database, to create tables, if they do not already exist. In terms
of ASP/ADO, that would be fine in a SQL Server Sense by a simply
ASP/Server-Side JavaScript as such:
var cnTemp = Server.CreateObject("ADODB.Connection");
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |