Hello all. Still failry new to OOP so please work with me on my lack of knowledge. 🙂
I have a class which controls my database connection. I have another class to display inventory levels of whatever I wish.
These are on two seperate pages called by includes. I am calling my database instande on my index.php page.
My questions are:
- Should I call a new instance of the data base connection within my inventory display class to make it recognize the database connection?
Would it automatically remember $this->connection outside of the class without using the extend function (I have PHP 4.3.9)?
It is good to create multiple classes for just about everything controlled within a website? I am making an automotive dealership sfotware package.
Am I going about this all wrong?
4. Is the goal of OOP to easily automate previously tedious tasks? Like functions?
By question 4, I mean: Should I be creating calsses for every little thing, or just for the stuff I have to do over and over. Creating functions for the other little stuff?
Here is a code snippet to show what I mean. I basically want to be able to utilize my database connection within the displayInventory class.
Thanks!
<?php
//db class is here
//inventory class here
$myDb = new dbConnect; //this starts my DB connection on my index page
?>