Forum Moderators: coopster

Message Too Old, No Replies

Using Classes

         

thawebmaster

2:28 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



I want to create one class that stores a few variables about a page. Let's call this class BaseSystem. Furthermore I want to create a few classes which can interact with eachother. However it's important that they can extract variables from the BaseSystem class.
How can I realize this?

Thanks in advance!

panic

2:46 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



What exactly are you trying to do?

-p

thawebmaster

2:51 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



Thanks for the quick reply. My English is not very well, so it's difficult to explain what I mean...

I want to create one "parent class" (the BaseSystem), which has a few children. One child is for the connection with the DB, another for fetching data from the DB about the current page. So I have a few other classes. These "chlidren" need to interact with eachother. For example: the "currentpage class" need the DB class for retrieving data from the DB.

Greetzz Tha WebMasteR

panic

2:52 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



I still have absolutely no clue what you're trying to do.

thawebmaster

2:58 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



I hope this will be displayed correct:

BaseSystem --> The main class, which stores information about the requested page
¦-> Database --> This is a class which needs to get the mysql_connect settings from the basesystem and is used for executing queries from other classes
¦-> CurrentPage --> This is the class which fetches the page from the db using the Database-class and analyses whether it might be displayed and so forth.

the lines starting with "¦->" are subclasses of the BaseSystem class.

My problem here is that the subclasses need to interact with eachother (The currentPage-class needs to access members at the Database-class).

Get it now?

panic

4:08 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



Nope.

You might be over-complicating things.

GaryK

4:42 pm on Nov 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think I understand what you mean. But I have to relate it to Visual Basic since most of sites are powered by a server-side ActiveX DLL file.

In VB you have a project that eventually gets compiled into a .dll file. Within that project you can have classes that do specialized things like handle database connections and queries, another to handle user input validation, another for formatting, and so on. I can call those classes from other classes or even directly from a web page.

I'm not sure this applies to PHP but hopefully it will help clarify what I think it is you're trying to do so that someone else who does know PHP can help you.

lorax

8:46 pm on Nov 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Won't the sub-classes become instantiated when the base-class is loaded or do you not instantiate them when the base-class is called?

Have you looked through this [us2.php.net] and this [us2.php.net]?

thawebmaster

11:17 am on Nov 23, 2003 (gmt 0)

10+ Year Member



When the BaseSystem is instantiated, the Constructor creates instances of all other classes. Not every time when the basesystem is used.

I think I can't use the "extends BaseSystem" in all other classes, because the BaseSystem is used to store a few variables and the classes can't interact with eachother.