Where should DB queries be implimented in OOP?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
FunkyDude
Forum Newbie
Posts: 8
Joined: Mon Dec 15, 2008 5:19 pm

Where should DB queries be implimented in OOP?

Post by FunkyDude »

Hello,

I'm having a little trouble understanding the implementation of DB queries in OOP.

The concept:
I want to create a class called createService.class.php. This class will 'create' a service, for example, I want to choose the price, description, options, etc.. After processing the information using the createService.class.php, I want the information added to a MySQL database (using mysqli i think). I will then be creating a createProduct.class.php, which will be a child class of createService.class.php. The purpose of this, is to say, create a service called "ad design" with a set rate and other custom variables. then use the create product class to make an "advertisment" which would have custom variables such as run date, ad size, etc.

The problem/question:
Since these 'create' classes add new DB entries into the system, I'm a little confused as to where I should build the sql query. Would I build it in the createService and createProduct classes, then pass the sql query to a separate DB class, or how would that work?
Post Reply