Current location: Hot Scripts Forums » Programming Languages » PHP » object manager class / object class


object manager class / object class

Reply
  #1 (permalink)  
Old 07-14-07, 12:36 PM
ther's Avatar
ther ther is offline
Newbie Coder
 
Join Date: Jul 2007
Location: Budapest,Hungary
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes object manager class / object class

Let's say I want to make a shop's database where everything has (id,name,price) in a MySQL table.

I saw two solutions for this with classes.
- The first one is using an Item class. When it's __construct is called it reads the informations from the MySQL table depending on it's $id. It stores the price and the name in a private variable and then it returns them on getPrice () and getName () functions.

- The second one is using an ItemManager class. It's like the Item class but the __construct function is empty and each function has $id parameter ( and it read's only the needed information every time, but sends query each function call ). This ItemManager class is a global variable and only contructed once.

Which one is better/more beautiful/faster/.... ? Or this only depends on how many items do we want look after in the MySQL table ? I'm waiting for replies based on this problem and about in what cases are one of the solutions more effective.

I could write example if that explains the problem better...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a child classes functions from a parent class? nautilian-force PHP 4 06-19-07 08:35 AM
conceptual problem: abstract class, interface or class UnrealEd Everything Java 2 05-12-07 07:30 AM
I need to pass this class Please Help! Negative6 Everything Java 1 05-03-07 06:55 AM
object class pkcidstudio PHP 2 07-19-06 03:48 PM
Object Oriented Programming Stefan PHP 29 12-30-03 11:22 AM


All times are GMT -5. The time now is 06:07 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.