Michiel
01-10-2004, 12:19 PM
Hi,
I've got a question concerning classes in php. I'm working on a multi-layered script and I'm having troubles with the general design. The script consists of 3 different layers: a common layer with the database functions, a business layer that does the actual operations and a gui layer. Now I'm looking for a way to connect these layers together in a flexible way. I want to be able to add new layers (with modules) without having to change the entire script.
So far I set up the following design:
class control {
function control() {
$this->common = new common;
$this->business = new business;
$this->gui = new gui;
}
}
class common {
function foo() {
}
}
class business {
function foo() {
}
}
class gui {
function foo() {
}
}
$object = new control;
$object->business->foo();
This design allows me to access all the functions in the different layers via $object->layername->functioname(). However the problem that I still have, is that I cannot call to functions between layers. Eg. from the business layer, I can't access a function from the common layer.
Does anyone know how I can solve this problem or suggest other/ better methods for the general design? Any tips, advice and reading is very much appriciated!
Thanx in advance, Michiel
I've got a question concerning classes in php. I'm working on a multi-layered script and I'm having troubles with the general design. The script consists of 3 different layers: a common layer with the database functions, a business layer that does the actual operations and a gui layer. Now I'm looking for a way to connect these layers together in a flexible way. I want to be able to add new layers (with modules) without having to change the entire script.
So far I set up the following design:
class control {
function control() {
$this->common = new common;
$this->business = new business;
$this->gui = new gui;
}
}
class common {
function foo() {
}
}
class business {
function foo() {
}
}
class gui {
function foo() {
}
}
$object = new control;
$object->business->foo();
This design allows me to access all the functions in the different layers via $object->layername->functioname(). However the problem that I still have, is that I cannot call to functions between layers. Eg. from the business layer, I can't access a function from the common layer.
Does anyone know how I can solve this problem or suggest other/ better methods for the general design? Any tips, advice and reading is very much appriciated!
Thanx in advance, Michiel