[PHP] learning classes - need pointer

2005-05-16 Thread Dustin Krysak
Hi there - I am slowly converting all of my projects over to a OOP  
based structure with classes. Now I had a quick question.

In my current case, I am trying to create all the generic SQL  
functions (IE insert, update, delete, etc). Now what I am wondering -  
what would be the best way to structure the code so that I can  
accommodate the possibilities for different fields and databases,  
etc? Is it something that I should just pass to the class? Or would  
there be a more efficient way to do it?

d
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] learning classes - need pointer

2005-05-16 Thread Alex Hogan
 
 In my current case, I am trying to create all the generic SQL
 functions (IE insert, update, delete, etc). Now what I am wondering -
 what would be the best way to structure the code so that I can
 accommodate the possibilities for different fields and databases,
 etc? Is it something that I should just pass to the class? Or would
 there be a more efficient way to do it?

 One of the things I hate most is having to rewrite code for insert and 
update. With that in mind what I do is name the form objects the same name 
as the db fields that they relate to. Then I iterate through the $_POST 
array as a whole and do the insertions and updates like that. The only thing 
that I have to pass to my class is the table name and any location string 
that will accompany the successful completion of the insert/update. All my 
validation is done right there with method overloading.
 It's not extremely clever by any means but it gets the job done. Besides 
I'm kinda lazy.
 I'm sure there are several wrappers that do the same thing.
  alex hogan