Jump to content

Recommended Posts

Bear with me--I've been doing php for a while, but am new to OO PHP...

 

In short, I'm trying to create a computing environment inventory/change checklist to use for when my business customers are moving or changing their business computing environment (adding servers/PCs, etc).

 

Rather than create a ginormous amout of session variables to track the inventory as it is built and edited as a result of using the web checklist interface, I'd like to create an object for each PC, Server, Router, Printer, etc.

 

I'm planning on creating an attribute for each object, "type," the value of which would be "server," "PC," "Printer," etc.

 

If I want to cycle through all the PC's for instance, how would I cycle through all the current objects that have attribute type "PC"?  In other words, what is the best way to approach the code and MySQL storage that when I want to see all  the PCs and display their attributes such as "name" and "installed software" I can do so?

 

Also, just to be clear, I'm not expecting anyone to spend a bunch of time writing the code for me.  If you can just point me in the right direction and maybe include a short example of a specific step, I would GREATLY appreciate it.  Thanks!

 

Firstly, objects (in any language) are used to describe 'things' of a specific 'type'. So making one generic 'thing' object and setting a 'type' property isn't likely to be a good design.

 

If these 'things' share attributes however you could have your objects inherit from a 'base' object which defined all the common attributes.

 

Next, objects don't persist by themselves. So, if your going to be storing there data within a database, just query the database for the data you need. No need to make objects that your not going to use.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.